I have a file called a.gz which is a gzipped file which contains the following lines when unzipped:
a
b
Below are two blocks of perl code which I think "should" give the same results but they don't.
Code #1:
use Data::Dumper;
my $s = {
status => 'ok',
msg => `zcat a.gz`
};
print Dumper($s),"\n";
Code #2:
use Data::Dumper;
my $content = `zcat a.gz`;
my $s = {
status => 'ok',
msg => $content
};
print Dumper($s), "\n";
Code #1 gives the following result:
Odd number of elements in anonymous hash at ./x.pl line 8.
$VAR1 = {
'msg' => 'a
',
'b
' => undef,
'status' => 'ok'
};
Code #2 returns the following result:
$VAR1 = {
'msg' => 'a
b
',
'status' => 'ok'
};
I'm using perl 5.10.1 running in Linux