Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Not a GLOB reference

by GeekyBrackets (Initiate)
on Dec 17, 2014 at 11:06 UTC ( [id://1110614]=perlquestion: print w/replies, xml ) Need Help??

GeekyBrackets has asked for the wisdom of the Perl Monks concerning the following question:

I get this error for the line: while($line = <$fh>) What does it mean and how can I resolve it? The entire code is:
use strict; use warnings; use v5.14; use Compress::Zlib; my $filename= "example.gz"; my $fh= gzopen($filename, "rb"); my $line=0; my $counter=1; my @array=(); [b]while($line = <$fh>)[/b] { @array= split (' ', $line); my $num = scalar(@array); print "$array[15] $array[1]\n" if ($array[15] eq "word"); $counter++; } close $fh;

Replies are listed 'Best First'.
Re: Not a GLOB reference
by choroba (Cardinal) on Dec 17, 2014 at 11:33 UTC
    Crossposted at StackOverflow. It's considered polite to inform about crossposting so people not attending both sites don't waste their time hacking a solution to a problem already solved at the other end of the Internet.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Not a GLOB reference
by Anonymous Monk on Dec 17, 2014 at 11:31 UTC

    Please use <code> tags to format your code as described here.

    You're trying to use the object returned by gzopen like a filehandle, but it's not; you should use the gzreadline method on the object. See the second example in the module's documentation. If you want a filehandle-like interface, take a look at IO::Uncompress::Gunzip.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1110614]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found