Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Parsing Multiple Lines.

by Zaxo (Archbishop)
on May 24, 2004 at 01:11 UTC ( #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,
Zaxo


Comment on Re: Parsing Multiple Lines.
Select or Download Code
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 parse.pl line 16, + <$fh> line 731.

      Use of uninitialized value in pattern match (m//) at parse.pl 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2014-09-22 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (189 votes), past polls