LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   perl printing (https://www.linuxquestions.org/questions/programming-9/perl-printing-188741/)

pantera 06-02-2004 03:27 AM

perl printing
 
how to match a field in a line and print the next line??

david_ross 06-02-2004 02:07 PM

What about something like:
Code:

# Loop through the lines
foreach $line (@lines){
 # If the last line matched then print it
 if($next eq "print"){
  $next="skip";
  print $line;
 }
 # If the line contains "somestring" then keep track in a variable
 if($line=~/somestring/){$next="print"}
}



All times are GMT -5. The time now is 05:49 AM.