$infile="hosts.txt"; open(INPUT, $infile) || die "Error opening $infile\n"; my @allhosts = <INPUT>; close INPUT; while ($approvhost=<STDIN>) { chop($approvedhost); # or it won't partially match # your hosts entries becaus of # the training \n unless ($approvedhost) { last; } # so you can quit # with a null entry foreach $host (@allhosts) # omit the <> you're not # reading a file or stdin { if ($host =~ m/^$approvhost/) { print $host; } } }
In reply to Re: matching a line from one file in another
by cormanaz
in thread matching a line from one file in another
by New_to_this_stuff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |