Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: How to delete conetents between two strings.

by mr_mischief (Monsignor)
on Sep 16, 2008 at 16:53 UTC ( #711749=note: print w/replies, xml ) Need Help??

in reply to How to delete conetents between two strings.

The easiest conceptually may be to use a flag variable to tell when you're between the markers. Your code can then print a copy only when the lines are not between the flags. This will process line by line, so it should use relatively little memory regardless of the length of the file and the length of the excluded sections.

This smells a bit like homework but could be very usful to any random sysadmin, too. I'm going to put the actual code in a spoiler tag and hope you choose honorably based on your situation.

Another way is to slurp the data and use a multi-line regex replacement. That won't take too much memory if there aren't too many lines (for some values of "too much" and "too many"). Implementation is left as an exercise.

There are likely many more exotic ways to handle this as well, but one or the other of the ones already mentioned should work for you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://711749]
[Veltro]: usemodperl Maybe it is the way you talk? 'Soy boys', 'old ladies' and what is even a tgimer...
usemodperl is venting, duh?
[usemodperl]: that was a typos, dumbass
[marto]: usemodperl I guess that depends on what you mean by a safe space, since many people seem to have the impression a safe space allows them to do/say whatever they feel like, without question or critque
[marto]: 'typos'->'typo'
[usemodperl]: it's like you guys are retarded or something, no sense of humor? autism?
[usemodperl]: take things too literally, nothing is funny, everyhting must be perfect, or else, SCOLD SCOLD SCOLD, haha
[Veltro]: usemodperl I think you are offensive right now.
[marto]: people are very defnsive about their bad ideas behaviour' :P
[usemodperl]: sorry veltro, venting...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2018-06-24 15:51 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.