perl.beginners
[Top] [All Lists]

Bug Or Feature?

Subject: Bug Or Feature?
From: Paolo Gianrossi
Date: Fri, 03 Oct 2008 18:21:35 +0200
Newsgroups: perl.beginners

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)?

cheers
paolino

-- 
Paolo Gianrossi
Softeco Sismat S.p.A. - R&D Division
via De Marini 1, 16149 Genova
Tel: +39 010 6026 332 - Fax: +39 010 6026 350
E-Mail: paolo.gianrossi@xxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>