Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Unable to get more than one line

by Sifmole (Chaplain)
on Jan 02, 2003 at 14:22 UTC ( #223775=note: print w/ replies, xml ) Need Help??


in reply to Unable to get more than one line

Your problem is that the  while (<F>) will only read a single line, and your  emp and /emp do not occure on the same line.

To do what you are trying to do here you could use  local $/; before the  while , to make Perl slurp in the whole data as one line. You will also need to alter the regex to use the s option ( which also has an extra paren at the end ):

$_ =~m/(<emp>.*<\/emp>)/s;
The /s says (simplified) to treat the whole string as a single line -- don't stop patterns at the newlines.

Of course if you are doing more than just toy-work with XML you might want to check out www.cpan.org and check out the libraries available there.


Comment on Re: Unable to get more than one line
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2015-07-07 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls