This assumes that your search text won't be across different lines.
open SEARCH, $file_to_search or die $!; my $count = 1; while (<SEARCH>) { if (/$regex_to_search_for/) { open FOUND, '>', "found$count.txt" or die $!; print FOUND $_; ++$count; } }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Search a text and output to different text files
by davorg
in thread Search a text and output to different text files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |