Listing 2. simple—search—2.pl

#!/usr/bin/perl -w
use strict;
use diagnostics;
# Iterate through each line of each file
while (<>)
{
# Print the matching filename and line
print "$ARGV: $_" if m/foo/;
}