[Melbourne-pm] Unexpected hashref behaviour

Alfie John alfiejohn at gmail.com
Fri Aug 17 02:51:17 PDT 2007


Hey Wes,

If you don't want the autovivification, you could try changing the dereference:

--- 8< ---

#!/bin/perl -w

use strict;
use Data::Dumper;

my $h = {};
$h->{ k } = undef;
print Dumper $h;
foreach my $k ( @{ $h->{k} || [] } ) {}
print Dumper $h;

administrators-powerbook-g4-12:~/tmp alfie$ perl t.pl
$VAR1 = {
          'k' => undef
        };
$VAR1 = {
          'k' => undef
        };

--- >8 ---

Alfie

http://www.Share-House.com.au
not the biggest address in property


More information about the Melbourne-pm mailing list