Created
September 22, 2011 18:42
-
-
Save ctfliblime/1235618 to your computer and use it in GitHub Desktop.
Why do these hashes have different contents?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
sub return_void { | |
return; | |
} | |
sub return_undef { | |
return undef; | |
} | |
my %h1 = (a=>1, b=>return_void(), c=>3); | |
print Dumper \%h1; | |
my %h2 = (a=>1, b=>return_undef(), c=>3); | |
print Dumper \%h2; | |
__END__ | |
Output is: | |
Odd number of elements in hash assignment at ./ptest.pl line 15. | |
$VAR1 = { | |
'a' => 1, | |
'3' => undef, | |
'b' => 'c' | |
}; | |
$VAR1 = { | |
'c' => 3, | |
'a' => 1, | |
'b' => undef | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment