What have you tried? What didn't work? As well, please wrap sample input in <code> tags, so formatting is preserved. See How do I post a question effectively?.
Your spec can be hit using regular expressions. Perhaps something like /(web site.{250})/i. You can then open your output file and print the contents of the capture buffer ($1).
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
| [reply] [d/l] [select] |
Assuming the specification is, “print the key phrase together with the following text up to 250 characters,” the regex would be better as /(web site.{0,250})/, which also matches when the key phrase is followed by fewer than 250 characters of text before the end of the file. As this match is greedy, it will match the largest number of characters up to 250.
Athanasius <°(((>< contra mundum
| [reply] |
This is what I have so far...
open (OUTPUT, ">Results.txt") || die ("Could not open file results.txt; $OS_ERROR");
open( INFILE, "Textfile.txt" )or die("Can not open input file: $!");
while (<INFILE>) {
if ($ARG =~ /Something/ ) {
print OUTPUT $ARG ;
}
}
close (OUTPUT);
| [reply] |