Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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.
--
<http://dave.org.uk>

"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?
Username:
Password:

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

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

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











    Results (167 votes), past polls