in reply to Re: Re: Re: Two lines Regular Expression
in thread Two lines Regular Expression

Thanks. Please advise how this catches the next line?
($_ .= <TMPLFILE>;)
what and how does it do that???

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Two lines Regular Expression
by allolex (Curate) on Jun 10, 2003 at 07:35 UTC

    It works by concatenating (with ".") the contents of $_ (your current line in this case) with the last line(s) read in. It is equivalent to: $_ = $_ . <YOURFILE>. You can have a look at perldoc perlop under "Assignment Operators" for a more detailed explanation.

    If you have:

    line one line two line three

    the first time around, $_ is "line one\n", the second time around, $_ becomes "line one\nline two\n", and the third time around, $_ becomes "line one\nline two\nline three\n", which allows you to use your regex across more than one line in the file.

    --
    Allolex

Re: Re: Re: Re: Re: Two lines Regular Expression
by hardburn (Abbot) on Jun 10, 2003 at 13:54 UTC

    That just uses a special kind of string concatanation operator to append the input. It's equvilent to $_ = $_ . <TMPLFILE>;

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated