http://www.perlmonks.org?node_id=838890


in reply to add new lines to output.

I think You have missed the patten matching operator. 
And with out checking pattern matching status , you are 
seeking for $1,$2,$3,$4 variables. If the matches get 
succeeded only then you can access those variables. 

So you check with if condition 
if ( $_ =~ ( regulare expression ) { # print the $1,$2,$3,$4 ..... }

Replies are listed 'Best First'.
Re^2: add new lines to output.
by Marshall (Canon) on May 07, 2010 at 09:23 UTC
    This is not the problem. The Op's regex guarantees that something of $1,$2,$3,$4 will be undefined even if the true/false sense of a "match" succeeds.
    For example, a line can only start with one thing. e.g, $2 and $3 cannot both be "defined" at the same time... A line can start with one of these 2 things or something else. "Query = " ">something"
    The Ops "Length = .*" term will never match unless the line didn't start with Query or > because the .* in those terms will "greedily" gobble up all the characters past those terms in the line. In that case $2 and $3 will be undefined. This is actually ok if that is what was intended.

    A reply falls below the community's threshold of quality. You may see it by logging in.