Random_Walk has asked for the wisdom of the Perl Monks concerning the following question:
Good $localtime honoured monks
I am having a little bother getting a hash slice from an anonymous hash to which I only have a reference. Without further ado some code
#!/usr/bin/perl -l # this works OK my @l=qw(this is); my %e=qw( this 7 is 6 then 9); print $e{is}; print join "+", @e{@l} # output 6 7+6 #!/usr/bin/perl # yet all my attempts to get this working failed # I tried @{$r->{@l}} @{$r->{@l}} and many more I forget my @l=qw(this is); my $r={qw( this 7 is 6 then 9)}; print $r->{is}; print join "+", @{$r->{@l}} # output 6 # just a blank line above.
What arcane combination of line noise like sigils will bring me enlightenment ?
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash slice from a hashref
by davorg (Chancellor) on Sep 07, 2006 at 13:52 UTC | |
|
Re: Hash slice from a hashref
by Fletch (Bishop) on Sep 07, 2006 at 13:51 UTC | |
by Random_Walk (Prior) on Sep 07, 2006 at 13:57 UTC | |
|
Re: Hash slice from a hashref
by VSarkiss (Monsignor) on Sep 07, 2006 at 14:02 UTC | |
by planetscape (Chancellor) on Sep 07, 2006 at 15:25 UTC |