in reply to Re^2: pattern matching question
in thread pattern matching question

Thank you AnomalousMonk (Vicar).

A few follow up questions. what is "-wMstrict -le" mean?

Also, can you explain this line a bit more? $s =~ s{ . .* \z }''xms; what does the \z and xms mean?

Replies are listed 'Best First'.
Re^4: pattern matching question
by kennethk (Abbot) on Jul 20, 2011 at 16:03 UTC
    When posting code, you need to wrap it in <code> tags so it doesn't get mangled - see Markup in the Monastery.

    Command line switches are documented in perlrun. The switches -w, -Mstrict, -l, and -e enable warnings, strict, automatic chomps and one-liner execution respectively.

    When you have questions about regular expressions, the go-to sources are perlre and perlretut. In this case, Assertions in perlre says

    \z  Match only at end of string

    and Modifiers in perlre says:

    m Treat string as multiple lines. That is, change "^" and "$" from matching the start or end of the string to matching the start or end of any line anywhere within the string. s Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which normally it would not match. Used together, as /ms, they let the "." match any character whatsoever, while still allowing "^" and "$" to match, respectively, just after and just before newlines within the string. x Extend your pattern's legibility by permitting whitespace and comments. Details in /x

    See also /x.