$fh, '>', $file or die "Can't open $_: $!\n";
print $fh @_ ;
}
The file JSON_FILE_NEW now looks like:
{
"JSON" : [
[
"a",
"b",
"c"
],
[
"g",
"h",
"i"
]
]
}
It's a bit quick and dirty hacked together, but I hope it will point you
in the right direction.
B.T.W. I tested this script using perl 5.20. I expect it to work with
older Perl versions as well.
Comments by others are welcome, of course.
Greetings,
Eric de Hont
Op 29-06-16 om 18:20 schreef Uri Guttman:
On 06/29/2016 06:03 AM, Eric de Hont wrote:
sub slurp_file {
my $file = shift;
local $/;
open my $fh, '<', $file or die "Can't open $_: $!\n";
$_ is not set anywhere. you likely meant to use $file
O, dear. Ju
Op 29-06-16 om 19:26 schreef Uri Guttman:
On 06/29/2016 01:17 PM, Eric de Hont wrote:
Op 29-06-16 om 18:20 schreef Uri Guttman:
since you are correct about modules being already there, why do you
write your own versions of
slurp_file and write_file? the module File::Slurp has those
functions
is better suited, or could at least be used in stead of the temp file.
Greetings,
Eric de Hont
e effect.
However, when you use perlbrew, which I recommend for development
purposes, you should use
#!/usr/bin/env. In production using env is considered dangerous by some,
because you have less
controll over which Perl is invoked.
Apart from the perldocs also have a look at https://perlmaven.co
Op 02-07-17 om 17:16 schreef Shawn H Corey:
On Sun, 2 Jul 2017 14:29:25 +0200
Eric de Hont wrote:
What it boils down to: use warnings as well as -w works, but -w is
considered old fashioned.
The problem with -w is that it can't be turned off. Sometimes a module
has to do something dang