dotykg has asked for the wisdom of the Perl Monks concerning the following question:
I am a “newbie” to the Perl world so please be patient with me. I am trying to understand why the following code snippet works as it does. As written, it gives “NOT a match”, which is the expected “textbook” behavior. But if B* includes zero matches, why isn’t the “C” a match? Even with the anchors I do not understand.
Many thanks, Kevin
$_ = 'C'; if ( /^B*$/ ) { print ' a match ...', "\n"; } else { print ' NOT a match ...', "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Anchors and zero matches question
by kennethk (Abbot) on Jan 07, 2011 at 22:58 UTC | |
|
Re: Anchors and zero matches question
by state-o-dis-array (Hermit) on Jan 07, 2011 at 23:02 UTC | |
|
Re: Anchors and zero matches question
by oko1 (Deacon) on Jan 08, 2011 at 01:51 UTC |