Error/Warning - what's "prettier" way of achieving purpose
david_dick at iprimus.com.au
Mon Nov 25 13:09:16 CST 2002
Scott Penrose wrote:
> On Monday, Nov 25, 2002, at 07:34 Australia/Melbourne, Rick Measham
>> At 6:34 AM +1100 25/11/02, David Dick wrote:
>>> print $cgi->header if (not defined $DEBUG); # slightly different, it
>>> won't print the empty string ;)
>> The whole point of 'unless' is to remove the 'if not' syntax so even
>> better would be:
>> print $cgi->header unless defined($DEBUG);
> I would tend to agree. The ternary operator (silly name isn't it :-)
> has some great uses. Especially so is if you want to provide a number
> of alternative inputs to a sub without wanting to use a temporary
> Therefore it would be 'reasonable' to do something like this.
> print "You are currently in " . (defined $DEBUG ? 'DEBUG' :
> 'PRODUCTION') . " mode";
> But in the example given where we need to do nothing if not debug,
> then Ricks example is probably the best.
i'd agree too. Mental note not to reply to emails just after waking up.
*pause* DOH!!! :)
More information about the Melbourne-pm