in reply to Hash assignments using map
#!/usr/bin/perl -w use strict; use Data::Dump qw(dump); my @keys = qw{ a b c d }; my %hash = map { $_++ } @keys; warn "Dump " . dump( %hash ) . "\n";
what I did get was,#!/usr/bin/perl -w use strict; use Data::Dump qw(dump); my @keys = qw{ a b c d }; my %hash = (); for (@keys) { $hash{$_}++; } warn "Dump " . dump( %hash ) . "\n";
Dump ("c", "d", "a", "b") # first script Dump ("a", 1, "c", 1, "b", 1, "d", 1) # second script
Neither answer seems to be exactly what you would I want, I think.
How about telling us what you are trying to do and see if we can address that issue?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash assignments using map
by njcodewarrior (Pilgrim) on Feb 24, 2007 at 18:32 UTC | |
by graff (Chancellor) on Feb 24, 2007 at 22:45 UTC |