Jeff Westman wrote:
>
> Rob Dixon <[EMAIL PROTECTED]> wrote:
>
> > [...snip...]
> > > > > return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;
> > > > Likewise, 'delete' returns either the element deleted or 'undef' if
> > > > it didn't exist.
> > [...snip...]
> > > I didn't know 'delete' returned the value as well. Simple and perfect!
> >
> > Having posted that I wondered whether you really meant what you wrote,
> > i.e. that you want to return and delete $Hash{$val2} based on whether
> > or not $myHash{$val1} exists. If that's correct then you still need
> > the conditional expression, but it seemed a little unlikely?
>
> I guess there are other ways to do it and this may be reduntant since if I
> can't delete the hash value, it will return undef anyway.
Be careful here Jeff as I'm not sure I've advised you correctly.
>From what you wrote it looks as though you may need something like:
my $retval = undef;
$retval = delete $Hash{$val2} if exists $myHash{$val1};
return $retval;
but there seems to be an unwritten relationship between
$myHash{$val1}
and
$Hash{$val2}
which I found unlikely.
Is this actually the case?
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]