develooper Front page | perl.perl5.porters | Postings from May 2015

Re: Use of uninitialized value in read - 5.20.2

Thread Previous
From:
Tony Cook
Date:
May 8, 2015 03:28
Subject:
Re: Use of uninitialized value in read - 5.20.2
Message ID:
20150508032806.GB17542@mars.tony.develop-help.com
On Fri, May 08, 2015 at 02:37:19AM -0000, Peter Scott wrote:
> I would appreciate any pointers on a peculiar issue I am having.  A 
> program that calls read() on a filehandle bound to a scalar is issuing 
> the warning "Use of uninitialized value in read".  What is most peculiar 
> to me is that this is on 5.20.2 and since each call looks like:
> 
>     my $bytes = read $fh, $$bufref, $length;
> 
> perl at this version should identity *which* value, and so it does in all 
> my one-liners.  So under what circumstances can perl emit this warning 
> from read without the value being identified?

The scalar you bound the file handle to is most likely undef:

$ ~/perl/5.20.1-dbg/bin/perl -Mwarnings -e 'my $x; open my $fh, "<", \$x; my $buf; my $sz = read($fh, $buf, 10)'
Use of uninitialized value in read at -e line 1.

Tony

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About