LogMiner has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Monks !
Have been chasing a bug in a large script, and finally distilled the issue into 3 lines. And for the life of me can't figure out what's going on. Here you go:
Basically, there are two identical grep calls, with a regex between them. This prints (at least in ActiveState Perl 5.12.3 on XP SP3):use strict; use warnings; print grep({"" =~ /$_/} (""))."\n"; "foo" =~ /foo/; print grep({"" =~ /$_/} (""))."\n";
Why in the world does the "foo" regex in the middle affect the second grep result ?1 0
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: grep trouble
by davido (Cardinal) on Apr 17, 2011 at 04:32 UTC | |
by LanX (Saint) on Apr 17, 2011 at 14:03 UTC | |
by davido (Cardinal) on Apr 17, 2011 at 16:08 UTC | |
by LanX (Saint) on Apr 17, 2011 at 16:21 UTC | |
by John M. Dlugosz (Monsignor) on May 14, 2011 at 16:09 UTC | |
by LogMiner (Novice) on Apr 17, 2011 at 14:04 UTC | |
by LanX (Saint) on Apr 17, 2011 at 15:45 UTC | |
by LanX (Saint) on Apr 18, 2011 at 10:37 UTC | |
Re: grep trouble (OT)
by Eliya (Vicar) on Apr 17, 2011 at 06:57 UTC | |
Re: grep trouble
by LanX (Saint) on Apr 17, 2011 at 15:14 UTC | |
by davido (Cardinal) on Apr 18, 2011 at 05:45 UTC | |
by LanX (Saint) on Apr 18, 2011 at 08:30 UTC | |
by LogMiner (Novice) on Apr 19, 2011 at 01:09 UTC | |
by davido (Cardinal) on Apr 19, 2011 at 04:11 UTC | |
Re: grep trouble
by anonymized user 468275 (Curate) on Apr 18, 2011 at 13:49 UTC |
Back to
Seekers of Perl Wisdom