LJ Archive

Listing 3. simple-search-3.pl

#!/usr/bin/perl -w
use strict;
use diagnostics;
# Get the pattern
my $pattern = shift @ARGV;
# Iterate through each line of each file
while (<>)
{
# Print the matching filename and line
print "$ARGV: $_" if m/$pattern/o;<\n>
}
LJ Archive