in reply to Re^2: grep in line and print
in thread grep in line and print
With use strict in effect, you need to declare your variable names:
my $allmac = ...
my $id = ...
But the line:
while (my $line = $allmac)
won’t work: it’s assigning the file name to $line, but it needs to call readline on a file handle, like so:
open (my $fh, '<', $allmac) or die "Can't open file '$allmac' for read
while (my $line = <$fh>)
Applying the diamond operator to a filehandle: <$fh> is the standard way to call readline in Perl. See readline and I/O Operators; also open and perlopentut.
Hope that helps,