Because in a //m, the end of string matching "f\n" is set before the '\n'
if the '\n' is trailing. The '\n' is skipped in the match, but the position after "f" isn't the end of the string:
perl -D512 -e '$_ = "f\n";/.*\z/'
Compiling REx `.*\z'
size 4 Got 36 bytes for offset annotations.
first at 2
rarest char
at 0
1: STAR(3)
2: REG_ANY(0)
3: EOS(4)
4: END(0)
floating ""$ at 0..2147483647 (checking floating) anchored(MBOL) impli
+cit minlen 0
Offsets: [4]
2[1] 1[1] 3[2] 5[0]
Omitting $` $& $' support.
EXECUTING...
Guessing start of match, REx ".*\z" against "f
"...
Found floating substr ""$ at offset 1...
Position at offset 0 does not contradict /^/m...
Guessed: match at offset 0
Matching REx ".*\z" against "f
"
Setting an EVAL scope, savestack=3
0 <> <f
> | 1: STAR
REG_ANY can match 1 times out of 2147483647
+...
Setting an EVAL scope, savestack=3
1 <f> <
> | 3: EOS
failed...
failed...
Guessing start of match, REx ".*\z" against "
"...
Found floating substr ""$ at offset 0...
Position at offset 0 does not contradict /^/m...
Guessed: match at offset 0
Setting an EVAL scope, savestack=3
1 <f> <
> | 1: STAR
REG_ANY can match 0 times out of 2147483647
+...
Setting an EVAL scope, savestack=3
1 <f> <
> | 3: EOS
failed...
failed...
Match failed
Freeing REx: `".*\\z"'
The matching isn't extended after the "\n". Whereas here
perl -D512 -e '$_ = "f\n";/.*\z/s'
Compiling REx `.*\z'
size 4 Got 36 bytes for offset annotations.
first at 2
rarest char
at 0
1: STAR(3)
2: SANY(0)
3: EOS(4)
4: END(0)
floating ""$ at 0..2147483647 (checking floating) anchored(SBOL) impli
+cit minlen 0
Offsets: [4]
2[1] 1[1] 3[2] 5[0]
Omitting $` $& $' support.
EXECUTING...
Guessing start of match, REx ".*\z" against "f
"...
Found floating substr ""$ at offset 1...
Guessed: match at offset 0
Matching REx ".*\z" against "f
"
Setting an EVAL scope, savestack=6
0 <> <f
> | 1: STAR
SANY can match 2 times out of 2147483647...
Setting an EVAL scope, savestack=6
2 <f
> <> | 3: EOS
2 <f
> <> | 4: END
Match successful!
Freeing REx: `".*\\z"'
you can see that the '\z' (<> in the debug output) is found after the "\n":
Setting an EVAL scope, savestack=6
2 <f
> <> | 3: EOS
2 <f
> <> | 4: END
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.