Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How can you do different things on certain lines in a text filedivided by separators?

Reply
Thread Tools

How can you do different things on certain lines in a text filedivided by separators?

 
 
hans
Guest
Posts: n/a
 
      03-01-2011
How can you do different things on lines in a file divided in rages,
for example:

aaa
..
..
.. insert "aaa" on every line between aaa and bbb
..
bbb
..
..
.. insert "bbb" on every line between bbb and ccc
..
..
ccc
..
.. etc.
..
 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      03-01-2011
hans wrote:
> How can you do different things on lines in a file divided in rages,
> for example:


What do you have so far?

perldoc -f open
perldoc perldocfaq6
 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      03-01-2011
J. Gleixner wrote:
> hans wrote:
>> How can you do different things on lines in a file divided in rages,
>> for example:

>
> What do you have so far?
>
> perldoc -f open
> perldoc perldocfaq6


Make that perldoc perlfaq6
 
Reply With Quote
 
George Mpouras
Guest
Posts: n/a
 
      03-02-2011

"hans" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How can you do different things on lines in a file divided in rages,
> for example:
>
> aaa
> .
> .
> . insert "aaa" on every line between aaa and bbb
> .
> bbb
> .
> .
> . insert "bbb" on every line between bbb and ccc
> .
> .
> ccc
> .
> . etc.
> .




while(<DATA>)
{
if ( /aaa/ .. /bbb/ ) {
print "line between aaa and bbb : $_" }

if ( /bbb/ .. /ccc/ ) {
print "line between bbb and ccc : $_" }
}


__DATA__
aaa
hello1
hello2
hello3
bbb
world1
world2
world3
ccc


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines? PerlFAQ Server Perl Misc 0 04-19-2011 10:00 AM
FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines? PerlFAQ Server Perl Misc 0 01-14-2011 05:00 AM
vs2005 publish website doing bad things, bad things =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?= ASP .Net 1 10-25-2006 06:18 PM
To delete few lines and add few lines at the end of a text file using c program Murali C++ 2 03-09-2006 04:45 PM



Advertisments