misterperl has asked for the wisdom of the Perl Monks concerning the following question:
what I'd prefer, as I'm averse to for () in general, is more like map s/something/something else/, over the values, and there is the problem. Is there some sensible construct to handle that sans looping? I'm considering something like map s/x/y/, @h{@k} ? Thanks, and Happy New Year to all.1. select keys with some regex like my @k = grep /something/,keys %h 2. loop over those keys like for ( @k ) { $h{$_} = some change } or { $h{$_} =~ s/stuff/other stuff/ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I want to operate on some values in a hash
by Eily (Monsignor) on Jan 04, 2018 at 16:15 UTC | |
by pwagyi (Monk) on Jan 05, 2018 at 01:49 UTC | |
by misterperl (Friar) on Jan 04, 2018 at 16:26 UTC | |
by Eily (Monsignor) on Jan 04, 2018 at 16:56 UTC | |
by karlgoethebier (Abbot) on Jan 04, 2018 at 17:24 UTC | |
|
Re: I want to operate on some values in a hash
by choroba (Cardinal) on Jan 04, 2018 at 18:02 UTC | |
|
Re: I want to operate on some values in a hash
by AnomalousMonk (Archbishop) on Jan 04, 2018 at 18:30 UTC | |
|
Re: I want to operate on some values in a hash
by thanos1983 (Parson) on Jan 04, 2018 at 16:19 UTC |