in reply to anonymous subroutines assigning regexes to hash keys
Others have pointed out other problems with your code, but your actual question has gone unanswered. (Well, I answered it when you asked in the CB earlier, but I guess you missed it.)
You're calling the anonymous sub in scalar context, which results in the match being evaluated in scalar context, and m// in scalar context returns whether a match occurred or not.
You need to call m// in list context or use $1 to access what the match captured. Here are two ways to fix your anon subs to return the desired value:
sub { ( /.*headline: (.*)/ )[0] },
sub { /.*headline: (.*)/ && $1 },
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: anonymous subroutines assigning regexes to hash keys
by donkeykong (Novice) on Jul 30, 2009 at 06:45 UTC | |
by ikegami (Patriarch) on Jul 30, 2009 at 07:06 UTC |