in reply to Re: Duplicating Pascal's with statement in Perl for anonymous data structures
in thread Duplicating Pascal's with statement in Perl for anonymous data structures
Try it with warnings next time ;-)
with %$anonhash, { name => 'dave', city => 'San Francisco', phone => '555-1212', hobbies => [ qw( Perl Anime ) ], # make the value into a scalar. };
I'd also make the minor change:
Just a bit more idiomatic, IMO.sub with(\%$) { my ($hash, $values) = @_; @$hash{keys %$values} = values %$values; }
|
|---|