in reply to null values
This has to be one of the most common initial questions that comes up about perl.
if ( defined( $q->param( "myinput" ) ) ) { print( $q->param( "myinput" ) ); }
or
my $value = $q->param( "myinput" ); print( $value ) if ( $value );
The above only works if $value is never going to be zero, because zero evaluates to false. A value of undef or zero is false. The following is safer:
my $value = $q->param( "myinput" ); print( $value ) if ( defined( $value ) );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: null values
by fluffyvoidwarrior (Monk) on May 26, 2005 at 08:15 UTC |
In Section
Seekers of Perl Wisdom