SPUG: In over my head with hashes of arrays of arrays
mike
mike206 at gmail.com
Fri Jul 22 17:03:41 PDT 2005
apologies in advance for any duplicates of this message.
is there any particular reason why you guys stick with the
'$hash{key}' or '$array[x]' method instead of using references?
Is it just a matter of preference?
Using references forces you to 'caste' the reference as an array (
@{$ref} ) or a hash ( %{$ref} ) when using stuff like push or keys.
Using actual arrays and hashes force you to \@array when passing to
subroutines.
Any other thoughs on this?
On 7/22/05, Adam Monsen <haircut at gmail.com> wrote:
> Good advice by all. Also, check out Data::Dumper, an invaluable tool
> at examining data structures of any kind.
>
> use Data::Dumper;
> $myhash{evens} = [ [0,2,4], [4,6,8] ];
> print Dumper(\%myhash); # notice the backslash!
>
> prints out:
>
> $VAR1 = {
> 'evens' => [
> [
> 0,
> 2,
> 4
> ],
> [
> 4,
> 6,
> 8
> ]
> ]
> };
>
> There's also a cool replacement to Data::Dumper that prints out the
> actual variable name instead of just $VAR1, but I forget what the name
> of that module is. I suppose you can also use Data::Dumper->Dump(),
> but this module that I can't remember the name of does everything for
> you.
>
> --
> Adam Monsen
> http://adammonsen.com/
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med
> WEB PAGE: http://seattleperl.org/
>
More information about the spug-list
mailing list