perl5ever has asked for the wisdom of the Perl Monks concerning the following question:
Just $x ne "" or testing the length alone doesn't work since I'd like to avoid the Use of uninitialized value ... warning in the case that $x is undef.use warnings; ... if (defined($x) && length($x)) { ... }
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: testing defined($x) && length($x)
by ikegami (Patriarch) on Mar 25, 2009 at 15:45 UTC | |
|
Re: testing defined($x) && length($x)
by kyle (Abbot) on Mar 25, 2009 at 15:53 UTC | |
|
Re: testing defined($x) && length($x)
by ruzam (Curate) on Mar 25, 2009 at 17:20 UTC | |
|
Re: testing defined($x) && length($x)
by Bloodnok (Vicar) on Mar 25, 2009 at 15:46 UTC | |
by ikegami (Patriarch) on Mar 25, 2009 at 15:50 UTC | |
|
Re: testing defined($x) && length($x)
by Herkum (Parson) on Mar 25, 2009 at 16:26 UTC | |
by kennethk (Abbot) on Mar 25, 2009 at 16:34 UTC | |
by Bloodnok (Vicar) on Mar 25, 2009 at 16:41 UTC | |
|
Re: testing defined($x) && length($x)
by JavaFan (Canon) on Mar 26, 2009 at 01:04 UTC |