ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
I know if it was just a simple hash, I could delete multiple fields with: delete @$foo{qw(testing something)} ..which would leave just "test" in there. However, I can't work out how to do it with a hashref. Any suggestions?my $foo = { testing => bar, test => test2, something => test3 }
..but my guess would be that using a single liner, would be more efficient (and cleaner ;))foreach (qw/fields here to delete/) { delete $foo->{$_}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove multiple fields from hashref?
by kcott (Archbishop) on Mar 12, 2014 at 07:10 UTC | |
|
Re: Remove multiple fields from hashref?
by Anonymous Monk on Mar 12, 2014 at 07:03 UTC | |
by Anonymous Monk on Mar 12, 2014 at 07:07 UTC | |
by ultranerds (Hermit) on Mar 12, 2014 at 07:05 UTC | |
by ultranerds (Hermit) on Mar 12, 2014 at 07:06 UTC | |
by Anonymous Monk on Mar 12, 2014 at 07:10 UTC |