jesuashok has asked for the wisdom of the Perl Monks concerning the following question:
hi monks
I have a little confusion in the below code's behaviour.
I found that the builtin variable $& is not having the reliable value in it.
Initially I tried to print the values available in $` and $'. but I found a misleading answer when I print $&.
I picked this code from a very large program.
I beleive that monks can definitely clear my doubts.
$_ = foo; /foo/; # prints "bar\n" for (qw/bar baz/) { print "$&\n" unless /bar/; } # prints "foo\n" for (qw/bar baz/) { next if /bar/; print "$&\n"; }
"Keep pouring your ideas"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: The value of pattern match variable $&
by McDarren (Abbot) on May 15, 2006 at 10:17 UTC | |
by spiritway (Vicar) on May 15, 2006 at 14:34 UTC | |
by ikegami (Patriarch) on May 15, 2006 at 15:07 UTC | |
Re: The value of pattern match variable $&
by cdarke (Prior) on May 15, 2006 at 09:04 UTC | |
by bart (Canon) on May 15, 2006 at 09:57 UTC | |
by ikegami (Patriarch) on May 15, 2006 at 15:12 UTC | |
Re: The value of pattern match variable $&
by Anonymous Monk on Nov 29, 2007 at 00:44 UTC |
Back to
Seekers of Perl Wisdom