in reply to dumping a hash
Add use strict; use warnings; at the start of every script you write. They will save you time! In this case the two errors in your hash assignment would have been flaged. One at compile time (two as a bareword) and the other at run time (the reference as 'Reference found where even-sized list expected').
and in the interests of TIMTOWTDI:
use warnings; use strict; use Data::Dumper; use Data::Dump::Streamer; my %hash = (this => 'one', that => 'two'); print "Dumpered:\n" . Dumper (\%hash); print "\nStreamered:\n"; Dump (\%hash); print "\nikegamied:\n"; foreach my $key (keys %hash) { my $val = $hash{$key}; print("$key => $val\n"); } print "\nGrandFathered:\n"; print "$_ => $hash{$_}\n" for keys %hash; print "\nmapped:\n"; print map {"$_ => $hash{$_}\n"} keys %hash;
Prints:
Dumpered: $VAR1 = { 'that' => 'two', 'this' => 'one' }; Streamered: $HASH1 = { that => 'two', this => 'one' }; ikegamied: that => two this => one GrandFathered: that => two this => one mapped: that => two this => one
|
|---|