Does Perl / m regex modifier change differently on Windows?

The following Perl statements behave the same on Unixish machines. Do they behave differently on Windows? If so, is it because of the magic \ n?

  split m/\015\012/ms, $http_msg;
  split m/\015\012/s, $http_msg;

I got a crash on one of my CPAN modules from a Win32 smoke tester. This seems to be the problem \ r \ n vs \ n. One change I made recently is to add // m to my regular expressions.

+5
source share
3 answers

For these regular expressions:

m/\015\012/ms
m/\015\012/s

Both / m and / s do not make sense.

  • / s: makes a .match \n. Your regex does not contain.
  • /m: ^ $ \n . ^ $, .

, (?) , \r (\015) Windows.

, ? \015

/\015?\012/

/m,/s m//. .

+12

\n. \n \r ASCII, \cJ \cM . ( EBCDIC ( ) MacOS Classic ( \n \r \cM).)

, Windows, , - , , \r\n \n . ( , \cZ - !) C.

binmode , .

/s /m : , (. ^/$, ), - .

+3

Why did you add /m? Are you trying to split into lines? To do this with /myou need to use ^or $in regex:

my @lines = split /^/m, $big_string;

However, if you want to treat the large string as strings, just open the file descriptor on the scalar link:

open my $string_fh, '<', \ $big_string;
while( <$string_fh> ) {
    ... process a line
    }
+1
source

All Articles