Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: grep in line and print

by Athanasius (Canon)
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,

Comment on Re^3: grep in line and print
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015078]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2016-05-30 11:33 GMT
Find Nodes?
    Voting Booth?