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

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

by davorg (Chancellor)
on Oct 30, 2006 at 13:42 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://581289]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found