develooper Front page | perl.perl5.porters | Postings from June 2008

[perl #8910] Subroutine doesn't create elements.

Thread Next
From:
=?ISO-8859-1?Q?Ren=E9e_B=E4cker?=
Date:
June 11, 2008 00:30
Subject:
[perl #8910] Subroutine doesn't create elements.
Message ID:
484F7F1B.6050204@smart-websolutions.de
The auto-vivification doesn't create SV's at all:

rbaecker@www-devel-rbaecker ~/perl510/bugs $ cat 8910.pl
#!/usr/bin/perl

use strict;
use warnings;
use Devel::Peek;

my @b = (undef,undef,undef,undef);
Dump \@b, 10;
test(@b);
print join " -> ", map {defined $_ ? $_ : "^^"} @b;

print "\n\n";

my @c;
$#c = 3;
Dump \@c, 10;
test(@c);
print join " -> ", map {defined $_ ? $_ : "^^"} @c;

print "\n";

sub test {
  $_[0] = 0;
  $_[1] = 1;
  $_[2] = 2;
  $_[3] = 3;
}
rbaecker@www-devel-rbaecker ~/perl510/bugs $ perl 8910.pl
SV = RV(0x8189260) at 0x815deac
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x8142c78
  SV = PVAV(0x8147284) at 0x8142c78
    REFCNT = 2
    FLAGS = (PADBUSY,PADMY)
    IV = 0
    NV = 0
    ARRAY = 0x81514c0
    FILL = 3
    MAX = 3
    ARYLEN = 0x0
    FLAGS = (REAL)
    Elt No. 0
    SV = NULL(0x0) at 0x8142180
      REFCNT = 1
      FLAGS = ()
    Elt No. 1
    SV = NULL(0x0) at 0x814239c
      REFCNT = 1
      FLAGS = ()
    Elt No. 2
    SV = NULL(0x0) at 0x8142c48
      REFCNT = 1
      FLAGS = ()
    Elt No. 3
    SV = NULL(0x0) at 0x814209c
      REFCNT = 1
      FLAGS = ()
0 -> 1 -> 2 -> 3

SV = RV(0x8189260) at 0x815de10
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x8175b74
  SV = PVAV(0x81472b0) at 0x8175b74
    REFCNT = 2
    FLAGS = (PADBUSY,PADMY)
    IV = 0
    NV = 0
    ARRAY = 0x8168798
    FILL = 3
    MAX = 3
    ARYLEN = 0x815deac
    FLAGS = (REAL)
    Elt No. 0
    Elt No. 1
    Elt No. 2
    Elt No. 3
^^ -> ^^ -> ^^ -> ^^
rbaecker@www-devel-rbaecker ~/perl510/bugs $

-- 

Renée Bäcker
renee.baecker@smart-websolutions.de

XING: http://www.xing.com/profile/Renee_Baecker
Foo-Magazin: http://foo-magazin.de


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About