[SP-pm] Dúvida sobre $1 em percorrer linhas.

Nelson Ferraz nferraz at gmail.com
Fri Sep 26 23:49:19 PDT 2008


> Não entendi, pois pelo que eu "sei" deveria funcionar da mesma forma, afinal
> os dois contém a mesma coisa.
> Então, estou me esforçando se eu não me engano eu estava falando com o
> Wendel um tempo atrás ou com o Blabos ou com o Gabriel,
> e tem um caractere que transforma tudo em uma linha só, pois acho que quando
> puxa direito da Internet ele não percorre todas as linhas,
> único problema que não lembro qual é esse caractere.

Se você RTFM (perldoc perlre), encontrará os quatro possíveis
caracteres que modificam o comportamento global da expressão regular:

i
    Do case-insensitive pattern matching.
    If use locale is in effect, the case map is taken from the current
    locale. See the perllocale manpage.

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.
    The /s and /m modifiers both override the $* setting. That
    is, no matter what $* contains, /s without /m will force
    ``^'' to match only at the beginning of the string and ``$'' to match
    only at the end (or just before a newline at the end) of the string.
    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.


More information about the SaoPaulo-pm mailing list