my $data = do { local (@ARGV, $/) = $filename; <> };
You may see why I chose to use File::Slurp originally. To integrate that into the second snippet, it would be:
#!/usr/bin/perl
use strict;
use warnings;
my $file = shift
or die "Usage: $0 file2 < another-file";
my $file_contents = do { local (@ARGV, $/) = $file; <> };
my $nets = join "|", map {chomp;$_} $file_contents;
/$nets/
or print
while <STDIN>;
Note: this code is untested.
Update: please note that some people get upset when you write "PERL." The language is called Perl, and the program that executes Perl code is called perl. Perl is not an acronym, so capitalizing its name makes it look like you're shouting. |