develooper Front page | perl.beginners | Postings from June 2010

Re: Use of uninitialized value in print at...

Thread Previous | Thread Next
From:
Uri Guttman
Date:
June 6, 2010 09:38
Subject:
Re: Use of uninitialized value in print at...
Message ID:
874ohgunfc.fsf@quad.sysarch.com
>>>>> "SHC" == Shawn H Corey <shawnhcorey@gmail.com> writes:

  SHC> On 10-06-05 03:26 PM, Bryan Harris wrote:
  >> [console]
  >> $ perl -e 'use warnings; $c=undef; printf("%s", $c->[0]{dog})'
  >> Use of uninitialized value in printf at -e line 1.
  >> [/console]
  >> 
  >> Anything that can help me here?  I wish it'd say:
  >> 
  >> Use of uninitialized value $c->[0]{dog} in printf at -e line 1.
  >> 
  >> ... but it doesn't.

  SHC> I wish it would say:

  SHC> Not an ARRAY reference in printf at -e line 1.

that is not happening due to autovivification. whenever you use an undef
like it was a reference, perl will allocate that for you and replace the
undef. this is very useful, much more than the issues it causes.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

Thread Previous | Thread Next


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