Hello, I am pretty new to perl (and programming), I have a script that is pretty much exactly what I need--the only problem I have is that it only returns the first match +/-10 chars. How can I modify this to return ALL matches in a document instead of just the first?
my $string = 'string to search for'; open (TEXTFILE, 'searchfile.txt'); $_ = join('',<TEXTFILE>); close (TEXTFILE) while (/(.{0,10})$string(.{0,10})/gis) { print "Found: $1$string$2\n"; }
In reply to Return multiple matches in file by sellwill
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |