in reply to Dereferencing a hash ref in an array ref

What is pretty?
print join "\n", @{ $sth->{NAME_uc} }, '';

Replies are listed 'Best First'.
Re^2: Dereferencing a hash ref in an array ref
by Schaelle (Novice) on Mar 26, 2010 at 07:54 UTC

    I just meant that the dereferencing using for the array deref the curly brackets, and for the hash deref the dereferencing using the arrow syntax. I thought its better only to use the second one, but dont know how that have to look like.

    Part 1:

    @{$hashref}

    Part 2 ("$hashref"):

    $sth->{NAME_uc}

    If thats already "pretty" (one syntax style for dereferencing) my thoughts just were wrong, would be an answer too.

    Greetings, Schaelle

      :) use Anonymous::Monk; no ESP;

      References quick reference

      You can only get scalars using the arrow syntax, you cant get multiple values

      my $sth = { NAME_uc => [ 1 .. 2 ] }; print join "\n" , $sth->{NAME_uc}[0 ,1 ]; __END__ 2
      my $sth = { NAME_uc => [ 1 .. 2 ] }; print join "\n" , @$sth->{NAME_uc}[0 ,1 ]; __END__ Not an ARRAY reference at - line 3.
      That is why you need curlies
      my $sth = { NAME_uc => [ 1 .. 2 ] }; print join "\n" , @{ $sth->{NAME_uc} } [0 ,1 ]; __END__ 1 2
      The arrow-less way
      my $sth = { NAME_uc => [ 1 .. 2 ] }; print join "\n" , @{ $$sth{NAME_uc} } ,'' __END__ 1 2
      References quick reference