in reply to create hash using grep
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
|
|---|