in reply to Re: Re: point to previous line
in thread point to previous line

hari,
What you want to do is create a flag variable as well as tell. This should give you an idea of how to get started.

The basic logic is this.

  • Store your position in the file with tell and read a line
  • Check to see if it contains data you are looking for
  • If no, reset the flag and move on as normal
  • If yes, check to see if your special flag is set
  • If yes, move on as normal
  • If no, go into sub-routine
  • When sub-routine returns, determine if it was succesful
  • If yes, move on as normal
  • If no, seek back to the position stored with tell, set your skip flag, use the redo command so that you do not actually read the next line in the file

    I am at work or I would actually write the code. If you need more assistance than the logic and the link to work this out, let me know and I will write it tonight when I get home.

    I hope this helps - cheers - L~R

  • Replies are listed 'Best First'.
    Re: Re: Re: Re: point to previous line
    by hari (Novice) on Mar 10, 2003 at 12:33 UTC
      hi, I thought tell and seek is the best and right way to do it.
      I have done it the following way.
      sub parent { while($line = <FILE>) { if(#line =~ something) { $parsed = child(*line,*FILE); if($parsed =~ /##_XYZ_##/) { my @tempArray = split /##_XYZ_##/,$parsed; $line = "$tempArray[1]"; redo; } else { continue...further.... } } } } sub child { my *cLine = shift; my *FILE = shift; my $temp = <FILE>; if(test($temp )) { return $cLine."##_XYZ_##"."$temp"; } else { ...continue further... } }

      Thanks for the support.