in reply to Re^2: warnings and grep problem
in thread warnings and grep problem

You're attempting to use the number of keys which matched to initialize a hash. Trying to use a single scalar to initialize a hash isn't going to produce anything useful.

my @desired_keys = grep { /\Q$dir\E.*?\.pm$/ } keys %$packlist; my %hash; @hash{ map { /\Q$dir\E(\w+?)\.pm$/; $1 } @desired_keys } = @desired_ke +ys;

Update: Gah. Me no write well. Reworded to (hopefully) clarify.

Replies are listed 'Best First'.
Re^4: warnings and grep problem
by jeanluca (Deacon) on Jun 20, 2006 at 16:36 UTC
    Ok, but what about this
    my @dirs = map { s/\Q$dir\E(\w+?)\.pm$/$1/, $1 } keys %$packlist; for (@dirs) { print "|$_|\n" if ( $_ and length($_) > 2 ); }
    This seems to work, but without the 'length($_) > 2' I get
    |1| |A_Module| |1| |An_Other_Module|
    Is there a better way to get rid of the 1s!