
FishMonger
Veteran
/ Moderator
Nov 21, 2013, 7:33 AM
Post #4 of 11
(2253 views)
|
Re: [perlFun] Trying to set array equal to a returned array, but it nests it
[In reply to]
|
Can't Post
|
|
what if this were an actual array though, and not an arrayref? It can't be an array Hash values are always a single element, not a list/array. So, if you need to hold multiple things under one key, then that value must be a reference to something else (i.e., an array_ref, hash_ref, code_ref, etc).
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $hashRef = {array_ref => [1,2,3], some_key => 'single thing' }; print Dumper $hashRef; foreach my $key (keys %$hashRef) { my $ref_type = ref $hashRef->{$key}; print "$key:$ref_type\n"; }
|