Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: grep in line and print

by Athanasius (Monsignor)
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2014-08-30 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls