in reply to Re: how to store an array to a pseudohash?
in thread how to store an array to a pseudohash?

Thanks for all the replies which are very instructive! (1) Thanks for leting me know that using following statement is referred to another hash which is not what I expected.
my $slice = { kind => $kind, prop => $prop, item => 5..11 };

(2) Thanks for pointing out the dereference method like:
my @items = @{$slice -> {item}};
I don't really understand why I need use @{} here to dereference, can somebody explain it for more details? I am just a Perl newbie :)
(3) Thanks for present a good program for data structure viewer -- Data::Dumper. I guessed I heard of it sometime ago, now I know how to use it. It's a good toolkit for debugging too.
(4) Thanks for criticizing my bad coding style (using map in a void context). I am digging into the link to find out why I should avoid to use this style... :)

Replies are listed 'Best First'.
Re^3: how to store an array to a pseudohash?
by TGI (Parson) on Jun 30, 2008 at 17:24 UTC
    (4) Thanks for criticizing my bad coding style (using map in a void context). I am digging into the link to find out why I should avoid to use this style... :)

    Don't be too hard on yourself for this one. Void map/grep have been argued over for years in the perl community. Some don't see a problem with it, others do. Definitely look into the issue and decide for yourself what is right.

    I'm personally neutral on void map. I use foreach in most cases where a void map could be used, because I think it more clearly expresses the intent of the code. However, I would have no problem using a void map if I thought it made things more readable.

    You might like to check out this nice article on void map


    TGI says moo

Re^3: how to store an array to a pseudohash?
by toolic (Bishop) on Jun 30, 2008 at 14:08 UTC
    I don't really understand why I need use @{} here to dereference, can somebody explain it for more details?
    By using the square brackets, you have created a reference to an array. Since you want to access the elements of the array reference, you first need to de-reference the array. One way to do so is to use the @{} syntax. Here are some good resources on the topic: