2
Well I have a perl script that formats a json leaving it in this format:
{"nome1":"123","nome2":"123","nome3":"123",}
but I want only in the last instance to remain only the key without the comma first. thus:
{"nome1":"123","nome2":"123","nome3":"123"}
Code:
open(FILEHANDLE, '<', 'prices.json');
my $file = <FILEHANDLE>;
close(FILEHANDLE);
open(salvar,'>>','730.json');
print salvar "{";
while($file =~ m/"name":"(.*?)","price":(.*?),/ig) {
my $name = $1;
my $price = $2 / 100;
print $name.":".$price."\n";
print salvar '"'.$name.'":"'.$price.'"'.",\n";
}
print salvar "}";
https://stackoverflow.com/questions/2468999/how-can-i-split-a-perl-string-only-on-the-last-occurrence-of-the-separator
– user60252