Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: multi-line parsing

by ELISHEVA (Prior)
on Mar 31, 2009 at 18:31 UTC ( #754495=note: print w/replies, xml ) Need Help??

in reply to multi-line parsing

Your multi-line regex is failing because you are comparing against a single line, not multiple lines. By default, Perl treats a new line as the record delimiter and so each time you loop you read in only one line, i.e. just "First line of text\n" or just "Second line of text\n" and so on - so your regex never matches.

For your above code to work, you will need to either (a) choose a different record delimiter by setting the $/ variable (see the section on $INPUT_RECORD_SEPARATOR in perlvar) or (b) by defining a variable to store and concatenate the lines you read in. Then you can compare your regular expression against that variable.

Does your data have a record delimiter other than a newline? Perhaps you could post a sample of the data you are tring to parse?

Best, beth

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2020-08-09 12:28 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (54 votes). Check out past polls.