help regarding Comparision of two lines



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";

.



Relevant Pages

  • Re: help regarding Comparision of two lines
    ... perticular line.in my file there is one line called "puts ... time occurance of puts... ... last part as a string and print the statements but after printing the ... If you want to search for the string "PORT TYPE address", ...
    (perl.beginners)
  • Re: help regarding Comparision of two lines
    ... perticular line.in my file there is one line called "puts ... time occurance of puts... ... If you want to search for the string "PORT TYPE address", ... puts $conCheckFail "# MEMORY CLOCKS" ...
    (perl.beginners)
  • Re: PMP 3/19/07
    ... I'm printing that one out for my teenage daughter, ... on a farm on weekends. ... As she puts it, ...
    (rec.arts.comics.strips)
  • insert a blank space
    ... How can I create a space that matches the size of a string of text? ... eg. \hspaceto puts a blank of a fixed size, ... Is there a command such as \blankthat inserts a gap that ... matches the size which would be occupied by printing `word'? ...
    (comp.text.tex)
  • Re: PayPal BUG - workaround??
    ... that prevents you from printing a prepaid shipping ... but that puts me only in a continual loop) ...
    (alt.marketing.online.ebay)