undef and "" are indeed different in Perl, but both are boolean false, so the test can be simplified to:
if (!$string) { }
See perlsyn#Truth-and-Falsehood.
Update: Except that "0" is also false, so if that’s a possibility, prefer BrowserUk’s solution, below.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Undefined vs empty string
by Athanasius
in thread Undefined vs empty string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |