in reply to Is $_ less than $X
|
The most devious part is japhy's innocuous comment. $(...) syntax is hogwash!
The $ starts the regex engine matching at the end of the string. Since $` is the portion preceding the current match, it gets set to the entire contents of $_. Now the (??{code}) zero-width assertion comes into play. $` >= $X is evaluated (as a string) and its result inserted into the regex. In Perl, boolean values stringify to "1" or "". So if $_ < $X, the comparison fails (returning ""), so the regex is simply /$/, which always succeeds. Otherwise, the comparison succeeds (returning "1"), and the regex is (equivalent to) qr'$1', which can never succeed. |
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is $_ less than $X
by japhy (Canon) on Jun 25, 2004 at 12:44 UTC |