Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: doubt in storing a data of 2 lines in an array.

by davorg (Chancellor)
on Oct 30, 2006 at 13:42 UTC ( #581289=note: print w/ replies, xml ) Need Help??

in reply to doubt in storing a data of 2 lines in an array.

You are reading the file a line at a time. So when you process the TITLE line, the data in $_ only contains the line that begins with TITLE. So that is all that ends up in $title. The rest of the TITLE data is processed on the next iteration of the loop (and, probably ends up as the first element in @se).

There are a couple of ways to solve this:

  1. Write a more complex parser. Keep a note of the _previous_ line's tag and if the current line starts with whitespace then append this data to the end of the previous tag.
  2. Read all the whole file into memory and parse it using more complex regular expressions.

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Comment on Re: doubt in storing a data of 2 lines in an array.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-11-28 05:48 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (738 votes), past polls