in reply to Search a string through IO::File API, and then print the lines after match in the file.

I don't see the point, but here goes anyway.

Without IO::File interfaceUsing IO::File interface
my $found; while (<$fh>) { if (/^222$/) { $found = 1; $last; } } print while <$fh>;
local *_; my $found; while (defined($_ = $fh->getline())) { if (/^222$/) { $found = 1; $last; } } print while defined($_ = $fh->getline());

  • Comment on Re: Search a string through IO::File API, and then print the lines after match in the file.
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Search a string through IO::File API, and then print the lines after match in the file.
by khurana.sanjeev (Initiate) on Sep 15, 2008 at 14:08 UTC
    Thanks a lot for reply. I feel perl API's would be using better searching methods then just searching the file from top to end. If they are not using, I agree my query doesn't make sense.