On Aug 3, 2005, at 10:01 AM, Louis Pouzin wrote:
> 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.
my $ref = \$H{one}{two}{three}[0];
# Either of these should work
delete %$ref{four} if exists %$ref{four};
delete $ref->{four} if exists $ref->{four};
But there may be a clearer way to design the code in the first place.
Josh
--
Joshua Juran
Metamage Software Creations - Mac Software and Consulting
http://www.metamage.com/
* Creation at the highest state of the art *
Thread Previous
|
Thread Next