Papo Napolitano wrote:
Gunnar Hjalmarsson wrote:
Papo Napolitano wrote:

$text =~ s/\r\n/<br>/gs;
-----------------------^

Why would the /s modifier make a difference? Please study

perldoc perlre

and figure out why it doesn't. ;-)

perl -e '$_ = "line1\r\nline2\r\n\r\nline4"; s/\r\n/<br>/gs; print'

Please test, and figure out why it DOES make a difference.

perl -e '$_ = "line1\r\nline2\r\n\r\nline4"; s/\r\n/<br>/g; print'

outputs exactly the same:
line1<br>line2<br><br>line4

(as expected).

Also study what "perldoc perlop" has to say about s///.
Look for "s/PATTERN/REPLACEMENT/egimosx" and especially the
description of the "s" modifier.

Sure, but the description in "perldoc perlre" is more complete, reducing the risk for misunderstandings: "Treat string as single line. That is, change ``.'' to match any character whatsoever, even a newline, which normally it would not match."

And there is no '.' in the pattern, is it?

As you may know s/// only matches to the end of line

No, I don't know that. What makes you believe so?

(And "\r\n" happens to be a line delimiter) unless you use the /s
modifier.

You are confusing the list members, Papo. It's time for *you* to test and revise your understanding of what /s does.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to