in reply to Re: Sad newbie question about Data::Dumper and array references..
in thread Sad newbie question about Data::Dumper and array references..

other than style is there a reason to prefer

print $data->[0];

over

print @{$data}[0];

--
my $chainsaw = 'Perl';

Replies are listed 'Best First'.
Re: Re: Re: Sad newbie question about Data::Dumper and array references..
by merlyn (Sage) on Mar 23, 2001 at 16:38 UTC
Re: Re: Re: Sad newbie question about Data::Dumper and array references..
by busunsl (Vicar) on Mar 23, 2001 at 13:54 UTC
    Nope

    I just find print $data->[0] looks more like dereferencing.

Re: Re: Re: Sad newbie question about Data::Dumper and array references..
by geektron (Curate) on Mar 23, 2001 at 13:52 UTC
    not that i can think of. there might be others to correct me, though.

     print @{$data}[0] is too many bracey-curly-making-me-hit-shift characters. they perform the same tasks.

      Actually, @{$data}[0] and $data->[0] perform slightly different tasks. The former creates an array containing one element (hence the @ at the start), whilst the latter creates a scalar (hence the $ at the start).

        hmmmm, which means I should have written-

        ${$data}[0]

        :-)

        --
        my $chainsaw = 'Perl';

Re: Re: Re: Sad newbie question about Data::Dumper and array references..
by tadman (Prior) on Mar 24, 2001 at 00:42 UTC
    It becomes apparent with more complex data structures, such as AoAoAoAoAoAoA's or HoHoHoHoHoHoHoH's, or any mutant variation thereof.      $data->[0]->[1]->[3]->[1]->[41]->[6] over      ${${${${${${$data}[0]}[1]}[3]}[1]}[41]}[6] Unless you're really good at counting brackets, I'd stick with the C-style dereferencing via '->'