kingman has asked for the wisdom of the Perl Monks concerning the following question:
Thanks! ~#!/usr/bin/perl -w use strict; #This works fine. my %s = ( a => 1, b => 2); @s{ qw(first second third) } = qw(one two three); dumph(\%s); #How do I do it here? my $t = { a => 1, b => 2}; #$t->{ qw(first second third) } = qw(one two three); # doesn't work. #@$t->{ qw(first second third) } = qw(one two three); # doesn't work. #$$t{ qw(first second third) } = qw(one two three); # doesn't work. # You're perl monk solution goes here!! dumph($t); sub dumph { my $hashref = shift; while (my ($k, $v) = each %{ $hashref }) { print "$k => $v\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I use hashref slices?
by danger (Priest) on May 29, 2002 at 18:35 UTC | |
|
Re: How do I use hashref slices?
by Ovid (Cardinal) on May 29, 2002 at 18:37 UTC | |
|
Re: How do I use hashref slices?
by Abigail-II (Bishop) on May 30, 2002 at 12:50 UTC | |
|
Re: How do I use hashref slices?
by sfink (Deacon) on May 29, 2002 at 18:39 UTC | |
|
(crazyinsomniac) Re: How do I use hashref slices?
by crazyinsomniac (Prior) on May 30, 2002 at 01:18 UTC |