in reply to Please help me print this hash.
That is the unexpected result that I gaet from the following code. Why is it making a hash?
Because this is what you wrote
%hash now contains a single key (keys are only strings), which is $hashref stringified (meaning no longer a reference). See for yourselfmy $hashref = {}; my %hash = $hashref;
$ perl -MData::Dump -e " dd { {} } " { "HASH(0x3f8a6c)" => undef }
Say it with me:
my $hashref = { 'hashes', 'are', 'curly', 'ones' };
my $arrayref = [ 'arrays', 'are', 'square' ];
my %hash = ( 'lists are round' , 'hashes want pairs');
I highly recommend perlintro, http://learn.perl.org/books/beginning-perl/, http://perl-tutorial.org/, Modern Perl , Tutorials: Basic debugging checklist , brian's Guide to Solving Any Perl Problem
|
|---|