On Fri, Jun 20, 2008 at 8:06 AM, Pat Rice <[EMAIL PROTECTED]> wrote:
>
> Hi all
>
> I am looking at a way of reading a line doing a regex to find the
> specific line then pick out the line, sudo code would be some thing
> like the following:
>
> read in line
> check regex
>
> if regex is correct
> {    jump 10 lines
>    print the output
> }

open(FILE,"") or die "Can't open file";
my $counter = 0;
my $print = 0;

#read line by line
while (<FILE>){
  my $line = $_;
  #regular exprecion
  if($line =~ /regexp/){
     #Start counting 10 lines
     $counter = 10;
     #is time to print
     $print = 1;
  }

  #Count 10 lines
  if($counter){
     $counter --;
     #go to next line and ignore the print block
     next;
  }

  #print
  if($print){
     print "$line";
  }
}

close FILE;

>
> any ideas on jumping the 10 lines, how do I ignore the lines in the
> file, and know I'm going the right distance ?
>
> Thanks
> Pat
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>



--
David Romero
www.factufacil.com.mx

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to