[Omaha.pm] map, grep in the debugger
Jay Hannah
jhannah at omnihotels.com
Tue Jun 29 13:30:15 PDT 2010
Was asked these today...
>From the Perl debugger, how can I see only those hash keys and contain
'DAY'?
$ perl -d -e 1
DB<2> %hash = ( FOO => 1, DAYLIGHT => 2, DAYTIME => 3, BAR => 4)
DB<3> x grep { /DAY/ } keys %hash
0 'DAYTIME'
1 'DAYLIGHT'
What if I want the keys and values where the keys contain 'DAY'?
DB<4> x map { $_ => $hash{$_} } grep { /DAY/ } keys %hash
0 'DAYTIME'
1 3
2 'DAYLIGHT'
3 2
Perl++ :)
j
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20100629/29a321cb/attachment.html>
More information about the Omaha-pm
mailing list