Chas Owens wrote:


><snip>
>> Alternately, you could say:
>> 
>> $track ||= '';
>> 
>> right before the next time you use foo after the split. I dont know 
why this
>> works offhand, I just remember reading in the docs somewhere that 
its exempt
>> from warnings. But for me, that is crossing over into the land of 
ugly =0).
></snip>
>
>$track ||= '';
>
>is equivalent to 
>
>$track = $track || '';
>
>which is equivalent to 
>
>if ($track) {
> $track = $track;
>} else {
> $track = '';
>}
>

When I said, "I dont know why this works...", I meant I dont remember 
why ||= is exempt from warnings. I know what it does.

Your examples are neither equivalent nor dangerous in the context of 
this thread. We are trying to avoid "undefined value..." warnings by 
the use of a variable after a split.

Im sure your second example is not exempt from the warning ,where 
$track ||= ''; is exempt.

also, The original OPs conditional following the split uses the eq 
operator with $track as one of its arguments, so the zero issue does 
not apply.

This was my second example, and my first suggestion to use:

if ( defined($track) and ( $track eq "foo") ) { ....

would be the most prudent IMHO.

Todd W

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to