Next | Welcome to my ~/bin | 69 |
The first half is just argument processing
sub do_file { my $file = shift; my $fh; if (ref $file) { $fh = $file; $file = "<stdin>"; } else { return if -d $file; unless (open $fh, "<", $file) { warn "Couldn't open '$file': $!; skipping\n"; return; } }
The function now has a filehandle to work with
The pattern matching is all here:
while (<$fh>) { chomp; if (/$qr/ ^ $opt_v) { $rc = 0; # match printf $format, $file, $_, $.; return if $opt_l; } } }
The /$qr/ ^ $opt_v thing harks back to $REVERSE in sortby
Next | Menu | Copyright © 2005 M. J. Dominus |