in reply to \n on a TXT file
It's wrong to use \1 in the substitution expression. You need to use $1.
Your code doesn't even compile. / in </TAG> needs to be escaped.
Once I fix those, it works for me.
use strict; use warnings; my $text; { local $/; $text = <DATA>; } $text =~ s/\#\#\#\n\[b\](.+)\[\/b\]/<TAG>$1<\/TAG>/g; print $text; __DATA__ ### [b]word[/b] text ###
<TAG>word</TAG> text ###
i guess that's because windows uses the combination "end of line+cr"
No. When reading a file, CRLF will be converted to LF automatically on read unless you tell it otherwise.
|
|---|