* Jos I. Boumans ([EMAIL PROTECTED]) [09 Jun 2001 10:32]:
> and for some abbreviation:

> $ENV{'HTTP_REFERER'} : $previous = $ENV{'HTTP_REFERER'} ? $previous = "an
> unknown site";

[...]
> god bless one liners =)

Surely you mean:

$previous = $ENV{HTTP_REFERER} ? $ENV{HTTP_REFERER} : 'an unknown site';

Only one use of the variable name, thus easier to maintain =)

Of course, there is a sideeffect in both this, the original and the one
the original is based upon:
   + If there was no key 'HTTP_REFERER' in %ENV, then there is now
     (albeit undefined).

Hence, you may really want:

$previous = exists($ENV{HTTP_REFERER}) && length($ENV{HTTP_REFERER})
                ? $ENV{HTTP_REFERER}
                : 'an unknown site';

(Note: && has higher precedence than ?:, but when in doubt, use parens)


cheers,
-- 
iain.                                          <http://eh.org/~koschei/>
Just don't compare it with a real language, or you'll be unhappy...  :-)
                    -- Larry Wall in <[EMAIL PROTECTED]>

Reply via email to