onegative has asked for the wisdom of the Perl Monks concerning the following question:
use strict; my $out; my $COUNT = 0; my $PORT = undef; my $PATH = "/usr/local"; my $CODE = ""; my $COUNT = ifnil($COUNT); my $PORT = ifnil($PORT); my $PATH = ifnil($PATH); my $CODE = ifnil($CODE); print "COUNT: $COUNT\nPORT: $PORT\nPATH: $PATH\nCODE: $CODE\n"; sub ifnil { my ($value) = @_; my $null = "null"; if ( $value eq "" ) { $out = $null; } else { $out = $value; } return $out; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: undef and empty variables
by tilly (Archbishop) on Jan 19, 2011 at 16:57 UTC | |
by herveus (Prior) on Jan 19, 2011 at 17:15 UTC | |
by tilly (Archbishop) on Jan 19, 2011 at 18:03 UTC | |
|
Re: undef and empty variables
by ikegami (Patriarch) on Jan 19, 2011 at 17:02 UTC | |
|
Re: undef and empty variables
by JavaFan (Canon) on Jan 19, 2011 at 17:20 UTC | |
|
Re: undef and empty variables
by locked_user sundialsvc4 (Abbot) on Jan 19, 2011 at 18:16 UTC | |
by locked_user sundialsvc4 (Abbot) on Jan 20, 2011 at 15:11 UTC |