in reply to Searching a pattern's first and last occurrence in a file.
a single huge line of 1000s of words
Slurp the file and use index, rindex and substr:
my $content = do{ local @ARGV = 'theFile.htm'; <> }; my $first = index $content, 'Oct-18-2013'; my $last = rindex $content, 'Oct-18-2013'; print substr $content, $first, $last;;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching a pattern's first and last occurrence in a file.
by ankurk (Initiate) on Oct 19, 2013 at 17:05 UTC | |
by BrowserUk (Patriarch) on Oct 19, 2013 at 17:14 UTC | |
by ankurk (Initiate) on Oct 19, 2013 at 17:51 UTC | |
by BrowserUk (Patriarch) on Oct 19, 2013 at 19:24 UTC | |
by ankurk (Initiate) on Oct 20, 2013 at 13:24 UTC |