in reply to What's the difference between $heap->{127.2}{127.1.0.2} and $heap->{'127.2'}{'127.1.0.2'} ?

Start your program with
perl -MO=Deparse,-p foo.pl
and compare the output to foo.pl
  • Comment on Re: What's the difference between $heap->{127.2}{127.1.0.2} and $heap->{'127.2'}{'127.1.0.2'} ?
  • Download Code

Replies are listed 'Best First'.
Re^2: What's the difference between $heap->{127.2}{127.1.0.2} and $heap->{'127.2'}{'127.1.0.2'} ?
by sunshine_august (Scribe) on Dec 22, 2008 at 09:21 UTC
    the output like this:
    use warnings; use strict 'refs'; (my $heap = {}); ($$heap{'172.16'} = 1); print("\$heap->{'172.16'}: $$heap{'172.16'}\n"); print("\$heap->{172.16}: $$heap{172.16}\n"); ($$heap{'127.2'}{'127.1.0.2'} = 2); print("\$heap->{'127.2'}{'127.1.0.2'}: $$heap{'127.2'}{'127.1.0.2'}\n" +); print("\$heap->{127.2}{127.1.0.2}: $$heap{127.2}{127.1.0.2}\n");
    and have the same executed result:
    $heap->{'172.16'}: 1 $heap->{172.16}: 1 $heap->{'127.2'}{'127.1.0.2'}: 2 Use of uninitialized value in concatenation (.) or string at testHash3 +.pl line 25. $heap->{127.2}{127.1.0.2}: