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.