princepawn has asked for the wisdom of the Perl Monks concerning the following question:
%parm = ( 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => 6 ); # useful for $object = Class::Name->new($x); # where only a subset of %parm is needed $x = { @parm{2..4} }; # fails $x = \@parm{2..4}; # fails $x = { 2 => $parm{2}, # trying to avoid 3 => $parm{3}, 4 => $parm{4} }; use Data::Dumper; print Data::Dumper->Dump([$x],['x']); print $/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: creates anonymous hashes with hash slices
by merlyn (Sage) on Aug 03, 2000 at 20:14 UTC | |
|
Re: creates anonymous hashes with hash slices
by tye (Sage) on Aug 03, 2000 at 20:54 UTC | |
by chip (Curate) on Aug 04, 2000 at 00:06 UTC | |
|
Re: creates anonymous hashes with hash slices
by ar0n (Priest) on Aug 03, 2000 at 20:17 UTC | |
by merlyn (Sage) on Aug 03, 2000 at 21:15 UTC |