Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^3: grep in line and print

by Athanasius (Chancellor)
on Jan 24, 2013 at 05:47 UTC ( #1015078=note: print w/replies, xml ) Need Help??

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 +ing: $!"; 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,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015078]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2018-04-26 03:00 GMT
Find Nodes?
    Voting Booth?