|
|
Question : How do you search for word in text file
|
|
open (FILE, "C:/file.txt") || die "Could not open source file for reading.\n"; while () { my ($name, $rpt, $type) = split (/\,/, $_); print "filename: $name rpt: $rpt, type: $type\n"; } close (FILE);
file.txt: abc-123,this is a test,test heck001,heck test file,heck
how can I make the script prompt for input? the input will contain full filename(heck001_20070614.txt), and it will match with what's on the file.txt if it match, then display the record.
|
Answer : How do you search for word in text file
|
|
print "filename: $name rpt: $rpt, type: $type\n" if ($input=~ m/^$name\d+\.txt/i);
|
|
|
|
|