in reply to how to store an array to a pseudohash?
As others have mentioned, psuedohashes were an experiment that didn't pan out, and are been deprecated in perl 5.8 and gone in perl 5.10.
I thought I'd add to what others have shown you here by suggesting that you try out Data::Dumper. It is very helpful when trying to understand datastructures. Try this code:
use Data::Dumper; my $slice = { kind => 'alph', prop => 'single', item => 5..11, } print Dumper $slice;
While you are looking at perldoc.perl.org, check out perldsc--the data structures cookbook. There's good stuff in there on setting up nested structures.
I also noticed that you use map to iterate over your @item_2 array, but don't use the return value--in other words, you are using map in a void context. Some people think this is a bad idea. Others don't have a problem with it. I don't really care, one way or the other. Anyhow, in case you decide you don't like void map, I'll show a couple of ways to do the same thing without raising that stylistic bugaboo:
# print takes a list of arguments # here map generates a list of args for one call to print. print map { "num is $num the $_\n" } @item_2; # simply replaced map with foreach used as a statement modifier. print "num is $num the $_\n" foreach @item_2;
TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to store an array to a pseudohash?
by Hanken (Acolyte) on Jun 29, 2008 at 11:46 UTC | |
by TGI (Parson) on Jun 30, 2008 at 17:24 UTC | |
by toolic (Bishop) on Jun 30, 2008 at 14:08 UTC |