Why does the code below not work ?
For a number of reasons. But mainly because grep returns the value of $_ and because your hash assignment is completely wrong?
Why not try turning on use strict and use warnings and see what it says.
You probably want something like this (untested):
my %a = %$a; my @keys = grep { ! /le/ } keys %$a; my %c; @c{@keys} = @a{@keys}; my $c = \%c;
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: create hash using grep
by davorg
in thread create hash using grep
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |