in reply to Re^2: Bug with "last successfully matched regular expression" (empty regex)
in thread Bug with "last successfully matched regular expression" (empty regex)

ARGH!!!!!!!!!

DB<52> @list= ("a".."c","DBIC","A".."C","DANCER","a".."c"); DB<53> sub ff { print $_[0]} DB<54> grep { ff(/DBIC/ .. /DANCER/) } @list; 0000000000 DB<55> grep { my $x=(/DBIC/ .. /DANCER/); ff($x) } @list; 12345E0

ff() evaluates the range operator in list context!

applying prototypes solves this "problem":

DB<182> @list= ("a".."c","DBIC","A".."C","DANCER","a".."c"); DB<183> sub ff ($) { print $_[0]} DB<184> grep { ff(/DBIC/ .. /DANCER/) } @list; 12345E0

Cheers Rolf ( ...banging his head against the table...)

Replies are listed 'Best First'.
Re^4: Bug with "last successfully matched regular expression" (empty regex) (list context)
by tye (Sage) on Feb 24, 2012 at 20:49 UTC

    Sorry, I thought your "guess which magic" was "an exercise for the reader" and that you already knew the answer or else I would've told you that when you posted.

    - tye        

Re^4: Bug with "last successfully matched regular expression" (empty regex)
by choroba (Cardinal) on Feb 24, 2012 at 15:40 UTC
    You can also use scalar to force scalar context:
    grep { ff(scalar(/DBIC/ .. /DANCER/)) } @list;