
FishMonger
Veteran
Mar 17, 2012, 12:43 PM
Post #8 of 12
(1115 views)
|
|
Re: [bgolivar] search string for a text file
[In reply to]
|
Can't Post
|
|
use strict; use warnings; print "Enter the File you want to search.\n" . '> ', chomp (my $filename = <STDIN>); print "Enter the search string:\n" . '> '; chomp (my $find = <STDIN>); open my $in_fh, '<', $filename or die "failed to open '$filename' <$!>"; my $outfile = 'output.txt'; open my $out_fh, '>', $outfile or die "failed to open '$outfile' <$!>"; print {$out_fh} grep(/$find/, <$in_fh>); close $in_fh; close $out_fh;
(This post was edited by FishMonger on Mar 17, 2012, 12:48 PM)
|