Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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]
[choroba]: I don't know. Maybe a new capability will be given to Hermits?

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2018-06-22 08:07 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (122 votes). Check out past polls.