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

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.

  • Comment on Re: Re: Re: Sad newbie question about Data::Dumper and array references..
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Sad newbie question about Data::Dumper and array references..
by tomhukins (Curate) on Mar 23, 2001 at 15:28 UTC

    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';

        $$data[0]
        would suffice. However while style may be the only reason to prefer one over the other, in this case style aids comprehension. I far prefer seeing:
        $data->[0]
        all day.