Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: grep in line and print

by Athanasius (Abbot)
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 having an uproarious good time at the Monastery: (12)
As of 2015-07-07 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls