in reply to if defined not working
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, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: if defined not working
by 1nickt (Canon) on Feb 04, 2016 at 16:39 UTC | |
by stevieb (Canon) on Feb 04, 2016 at 17:01 UTC | |
by mr_mischief (Monsignor) on Feb 04, 2016 at 17:38 UTC |