Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: parsing a multi-line pattern and replacing

by InfiniteSilence (Curate)
on Apr 24, 2014 at 19:41 UTC ( [id://1083676]=note: print w/replies, xml ) Need Help??


in reply to parsing a multi-line pattern and replacing

Here's how you would select the information you want. I'll leave it as an exercise to modify the code to replace the values.

#!/usr/bin/perl -w use strict; my $wholefile = ''; while(<DATA>) { $wholefile .= $_; } while($wholefile=~m/\<default\>([^\>]+)\<\/default\>/gs) { print qq~$1\n~; } 1; __END__ this is line 1 this is line 2 <default>sometext</default> this is line 3 <default>some more text some more in next line </default> this is last line

Prints...

sometext some more text some more in next line

Celebrate Intellectual Diversity

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-20 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found