Hello liorlew, and welcome to the Monastery!
choroba and stevieb have answered your question, but I want to point out that Perl has the useful logical defined-or operator //, which allows you code this more concisely and expressively:
use strict; use warnings; my $undefvar; ... my $newvar = $undefvar // 0;
See perlop#Logical-Defined-Or.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: if defined not working
by Athanasius
in thread if defined not working
by liorlew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |