in reply to Stringifying undefs

my $foo = undef; print "\$foo = " . ($foo || 0);

Replies are listed 'Best First'.
Re: Re: Stringifying undefs
by TimToady (Parson) on Mar 02, 2004 at 01:03 UTC
    Or, if you have warnings turned off:
    print "\$foo = " . ($foo + 0);
      use warnings; my $foo = undef; print "\$foo = " . (++$foo-1);