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";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/