On Fri, 2008-10-03 at 18:21 +0200, Paolo Gianrossi wrote:
> Here's my problem (well, a shortened example=)
>
> #hashes.pl
> use strict;
> use warnings;
>
> use Data::Dumper;
>
> my %a=(a=>1, b=>2, c=>3);
> print Dumper \%a;
>
> print "\n".("-" x 10)."\n";
>
> my $c=$a{d}->[0];
>
> print Dumper \%a;
>
> $ perl hashes.pl
>
>
> $VAR1 = {
> 'c' => 3,
> 'a' => 1,
> 'b' => 2
> };
>
> ----------
> $VAR1 = {
> 'c' => 3,
> 'a' => 1,
> 'b' => 2,
> 'd' => []
> };
>
>
> Now, while I'd expect a warning on the line of my $c=$a{d}->[0]; (like,
> dunno, you're trying to dereference undef?) I'd never think a field is
> added to the hash...
>
> I'm confused.. Is this expected behaviour? Changing a right-hand operand
> (without calling a sub)?
Perl does this even if you're just testing. I don't know why.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Indent = 1;
$Data::Dumper::Maxdepth = 0;
my $var = {};
if( exists $var->{foo}{bar}[5] ){
print "foobar\n";
}
print Dumper $var;
__END__
--
Just my 0.00000002 million dollars worth,
Shawn
Linux is obsolete.
-- Andrew Tanenbaum
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/