rastoboy has asked for the wisdom of the Perl Monks concerning the following question:
But sometimes I get just a single hash ref with the same data, and what I'd like to know how to do is force it into a list so that I can use the above loop to process it as a single element list. Sounds easy, right? But I'm getting no where with for example:foreach my $response ( @ $address ) { print "name: $response->{Addressee}<br>"; print "street: $response->{Street}<br>"; ...etc.
orif ( ref $address eq HASH ) { my $templist = [ $address ]; }
Which seems logical to me, but when I print or ref the new variable I get nothing, when I'm expecting "ARRAYx...". Clearly I'm misunderstanding something here..and I'd be grateful for any feedback!if ( ref $address eq HASH ) { push my @templist, $address; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pushing a hashref into an array
by gmargo (Hermit) on Nov 08, 2009 at 10:20 UTC | |
|
Re: Pushing a hashref into an array
by 7stud (Deacon) on Nov 08, 2009 at 13:01 UTC | |
|
Re: Pushing a hashref into an array
by Anonymous Monk on Nov 08, 2009 at 10:09 UTC | |
|
Re: Pushing a hashref into an array
by Bloodnok (Vicar) on Nov 08, 2009 at 17:53 UTC | |
by rastoboy (Monk) on Nov 11, 2009 at 12:49 UTC |