in reply to Searching through a file

The only thing I'd add to what mr_mischief and ikegami have said, is that it can be useful to use __DATA__ to set up some test data before your loop and then test to see that your loop does what you want it to, as so:

#!/usr/bin/perl use warnings; use strict; # # Using __DATA__ to test a loop. # my $string = 'test'; my $inputs = 'test.txt'; # open(my $table, "<", $inputs) or die "can't open $inputs.\n"; # while (<$table>) { while (<DATA>) { print if ( m/\Q$string\E/o ); } # close($table); __DATA__ test tst foo bar test This is a test This is something else.
The output is:

C:\Code>perl match.pl test foo bar test This is a test