Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2017-11-22 02:20 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (314 votes). Check out past polls.