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.
> > I know perl returns the last value (statement?) by default,
>
> The returned value is the value of the last executed statement as
> long as that statement was an expression. If not then I'm unclear
> as to the exact behaviour.
> [...snip...]
> returns the empty string (false, but not 'undef')
>
> Maybe somebody else knows?
>
> > but doesn't it make it more readable (or self-documenting) to
> > the next person who may come along what my intent is?
>
> IMO it would make it more obvious and wouldn't do any harm, but I've
> seen very little code written like that. It depends on whether you
> want your code to be 'familiar' or 'explicit'. Take a look at
Since we use so many different coding languages in our shop, I just want to
make the "obvious" definitive. Not everyone in this shop uses perl (most use
Java), so I just wanted to be clear in my intention(s) in the code...
-Jeff
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]