in reply to doing something with the rest of a file after matching a keyword

Depending on how you process the file (line by line, as a whole, ...) and on how you find the keyword, the following might be another alternative.

Slurp the whole file into a variable and use a regex to extract the part you want - or delete the part you don't want.

open my $file, '<', "$filename" or die $!; my $text = do { local $/; <$file> }; # get the part you want my ($wanted) = $text =~ /Well(.*)/s; # or delete the stuff you don't want $text =~ s/.*Well//s;
You might have to 'massage' the regex a little to fit your exact needs ...

-- Hofmator

  • Comment on Re: doing something with the rest of a file after matching a keyword
  • Download Code