in reply to split, Use of uninitialized value

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Re: split, Use of uninitialized value
by pg (Canon) on Jan 07, 2004 at 03:30 UTC

    The condition for autovivification is not meet in this case. See below demo:

    use Data::Dumper; use strict; use warnings; my $a = ["abc","cba"]; if (defined($a->[2]) && $a->[2] ne '') { } print Dumper($a); if (defined($a->[2]->[3]) && $a->[2]->[3] ne '') {#this is autovivific +ation } print Dumper($a);

    Here is the result from above code:

    $VAR1 = [ 'abc', 'cba' ]; $VAR1 = [ 'abc', 'cba', [] #this is autovivification ];
Re: Re: split, Use of uninitialized value
by thelenm (Vicar) on Jan 07, 2004 at 03:44 UTC

    Autovivification doesn't happen in this case, e.g.

    my $foo = [qw(a b c)]; if (defined $foo->[4]) { print "this will not print\n"; } print join('|', @$foo), "\n";

    ... prints "a|b|c" instead of "a|b|c||" as you would expect if autovivification had occurred.

    -- Mike

    --
    XML::Simpler does not require XML::Parser or a SAX parser. It does require File::Slurp.
    -- grantm, perldoc XML::Simpler