in reply to Re^2: from array to hash with grep
in thread from array to hash with grep
my @inp = ("abc_A_bla", "abc_B_bla", "abc_C_bla"); my %inp = map { /\w{3}_(\w)/; $1 => $_ } @inp ; foreach ( keys %inp ) { print "$_ => $inp{$_}\n"; }
Update: Better to use bart's version which includes checks for when the regex doesn't match.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
---|