in reply to Searching for strings specified via user input
There's the core module Term::ReadLine, and the CPAN module Term::Prompt - see their documentation for examples. Once you've got the string from the user, you can split it to get your @pats. Something like this:
use Term::ReadLine; my $term = Term::ReadLine->new("prompt"); my $input = $term->readline("Enter search pattern: ") or die "no search pattern entered"; my @pats = split ' ', $input;
Another note: I see you've not checking the return value of your open for errors, which you may want to do:
my $infile = shift; open(my $in, "<", $infile) or die "Failed to open $infile: $!"; my $outfile = shift; open(my $out, ">", $outfile) or die "Failed to open $outfile: $!";
Either that, or add an use autodie; at the top of your script - see autodie.
|
|---|