Forum Moderators: coopster & phranque

Message Too Old, No Replies

Anonymous Hashes

         

Davo1977

8:52 pm on Oct 14, 2008 (gmt 0)

10+ Year Member



Does anyone have any examples regarding Anonymous Hashes in Perl.
I am struggling to get to grips with Creating and referencing anonymous hashes.

I need to see how elements can be accessed by dereferencing the reference and adding a key/value pair to the anonymous hash.

How else can i analyse a anonymous hash?
Any help appreciated, many thanks.

phranque

11:42 pm on Oct 14, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



this "perl reference" reference [perldoc.perl.org] should be a good place to start.

Davo1977

10:19 am on Oct 15, 2008 (gmt 0)

10+ Year Member



I didn't find this source helpful enough. Any other references available. Im also looking at multi-dimensional structures.

phranque

11:06 am on Oct 15, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



here's an anonymous hash assigned to a scalar reference:
$hashref = {
'one' => '1',
'two' => '2'
};

add a key/value pair by dereferencing (with brackets):
${$hashref}{"three"} = 3;

if you post an example of what you are trying to do we could work on that to improve your understanding.
maybe mine as well...
=8)