Error/Warning - what's "prettier" way of achieving purpose

David Dick david_dick at iprimus.com.au
Sun Nov 24 13:34:16 CST 2002



ADFH wrote:

>Some code I've written has following line..
>
>print   (!defined $DEBUG) ? $cgi_int->header : '' ;
>
>Basically, if I'm debugging, a content type header is printed
>elsewhere.. With the above line I get the following message:
>
>"Useless use of a constant in void context"
>
>Should I be using a full-blown if statement?
>Should I be using a different way of saying null?
>Is there a different structure I should be using?
>
You could use

print ((! defined $DEBUG) ? $cgi->header : '');

or

print $cgi->header if (not defined $DEBUG); # slightly different, it 
won't print the empty string ;)

as to whether you should.... What are you trying to achieve? Quick and 
dirty prototyping? Application for others to maintain?

>
>ADFH
>
>  
>




More information about the Melbourne-pm mailing list