Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Parsing Multiple Lines.

by Zaxo (Archbishop)
on May 24, 2004 at 01:11 UTC ( [id://355803]=note: print w/replies, xml ) Need Help??

in reply to Parsing Multiple Lines.

Your routine already distinguishea between data lines and blank (well, nonword) ones. You just haven't used the information. Add an else clause to the end of the if ($line=~/(\w)/) { statement, like:

} else { print "This line intentionally left blank.\n"; }
For other ideas, you could chomp and then test length, or else test for not matching non-whitespace: $line !~ /\S/. Each suggestion accomodates a little different notion of which lines are considered blank.

You probably mean to print whole lines, rather than just what you captured ($1).

After Compline,

Replies are listed 'Best First'.
Re: Re: Parsing Multiple Lines.
by /dev/trash (Curate) on May 24, 2004 at 01:48 UTC
    After posting my question, I did one more search and came up with this reply to a question: Re: multi-line regex match quest It works to a point but I get this:
    Use of uninitialized value in pattern match (m//) at line 16, + <$fh> line 731.

      Use of uninitialized value in pattern match (m//) at line 16, <$fh> line 731

      A warning that tells you the variable you perform a pattern match was empty at the point given
      (line 16 in your code and line 731 in the file you're reading from.)

        I am confused then. I am getting that warning for a LOT of the lines in the text file.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://355803]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-18 00:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found