develooper Front page | perl.macperl | Postings from August 2005

[MacPerl] using references with hashes

Thread Next
From:
Louis Pouzin
Date:
August 3, 2005 13:52
Subject:
[MacPerl] using references with hashes
Message ID:
200508031401.j73E1wcr000404@ares.enst.fr
Good morning/afternoon/night,

To avoid cluttering scripts with intricate expressions I tried references, 
with mixed results. e.g. instead of:

   delete $H{one}{two}{three}[0]{four} if exists $H{one}{two}{three}[0]{four};

I'd prefer to write:
   $ref = \$H{one}{two}{three}[0]{four};
   delete $$ref if exists $$ref; # or somesuch.

While I could get each, keys, and values, out of references, I haven't figured 
out a working syntax for exists, delete, and growing hashes.

Perhaps someone could suggest a right way. Thanks.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About