help regarding Comparision of two lines
- From: hemanth004@xxxxxxxxx (Raaki)
- Date: Wed, 26 Sep 2007 04:09:58 -0700
hi friends
recently i started learning perl.i need to print some statements after
perticular line.in my file there is one line called "puts
conCheckFAIL#-----------"occuring number of times.i need to print some
statements after the 6th time it occuered.can you help me with that
puts \$conCheckFail
\"#-------------------------------------------------\"\n"; # 5th time
occurance of puts...
puts \$conCheckFail \"# CONNECTIVITY CHECK ERRORS FOR PORT TYPE address
\"\n";
puts \$conCheckFail
\"#-------------------------------------------------\"\n"; # 6th
time occurance of puts...
i try to write the code as below .trying to compare the above line
last part as a string and print the statements but after printing the
print statements the 6 th occurance is printing again .can u help in
any way solving this either when the 6th time it appeared i needto
print my print statements and rest of the file text need to be the
same...
rename "$ARGV[0]", "$ARGV[0].tmp";
open INPUT, "$ARGV[0].tmp";
open OUTPUT, "> $ARGV[0]";
while (<INPUT>) {
if ($_=~"PORT TYPE address") {
print ..
print ..
print ..
print ..
} else {
print OUTPUT "$_";
};
}
unlink "$ARGV[0].tmp";
rename "$ARGV[0]", "$ARGV[0].gate";
.
- Follow-Ups:
- Re: help regarding Comparision of two lines
- From: Yitzle
- Re: help regarding Comparision of two lines
- Prev by Date: help regarding Comparision
- Next by Date: win32 serial port
- Previous by thread: help regarding Comparision
- Next by thread: Re: help regarding Comparision of two lines
- Index(es):
Relevant Pages
|