On Sun, Jun 6, 2010 at 08:19, Shawn H Corey <shawnhco...@gmail.com> wrote: > 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. > > I wish it would say: > > Not an ARRAY reference in printf at -e line 1. snip
But that is not the problem; autovivification will create the references: perl -MData::Dumper -le '$c->[0]{a}; print Dumper $c' The problem is that $c->[0]{dog} doesn't have anything in it (i.e. it is undef). The error message should theoretically be able to find that the problem is linked to the variable $c like this one does: perl -we 'my $c; printf "%s", $c' but the problem with that is it is only indirectly linked with $c and you could have a situation like perl -wle '$c={a=>1,b=>2}; print $c->{z}, $c->{b};' If the warning said the problem was with $c, you wouldn't know which expresion was undef, and it might lead you to think that the problem was with $c, not the fact that you used "z" instead of "a" as a key. You could make the error message mention the hashref, but, since data structures can be arbitrarily deep, that could get nasty quickly. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/