Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: match and remove across multiple lines

by xenchu (Friar)
on Apr 25, 2004 at 01:35 UTC ( #347912=note: print w/replies, xml ) Need Help??

in reply to match and remove across multiple lines

I couldn't get Enlil's code to work until I changed:

print unless ( /^Header1$/ .. /^END LIST$/ );


print unless ( /Header1/ .. /END LIST/ );

As originally coded every line was printed.

Update: I did get Enlil's code to work on Solaris 5.9. The only machine it did not work on was the one with Mandrake Linux on it. I have no explanation for that.


That's about all there is to it, except for everything else. -<b>Programming Perl</b> (p.346)

Replies are listed 'Best First'.
Re^2: match and remove across multiple lines
by Anonymous Monk on Jan 28, 2006 at 03:15 UTC
    Here is a sample code that works for me. I basically hv to direct the output to another file when I run the script and its working fine. But is there any way to manipulate the insert within the source file itself?.

    Also I am worried about the large xml file and how my memory might be effected

    while (<FILE>) { $match++ if $match; if(/$same/){ # When we see <pattern> start storing the data $match = 1; } $match = 0 if (/APPLES=*/); next if ($match == 1); next unless $match; s/\<Row AutoFitHeight=*//; print "$_"; } foreach $o(sort keys %{$application{$key}}){ print $boots{$s}{$o}\n"; } else { print "0\n"; } } print " $cnt{$s}\n"; print " $date\n"; } close (FILE)

    Edit: g0n - code tags

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://347912]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2018-07-21 06:18 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (444 votes). Check out past polls.