in reply to Re^4: Problems with HOHOH modification
in thread Problems with HOHOH modification

Yes!

|| returns the value that dictated the outcome of the operation - either the left hand value if it was true, or the right hand value if the left is false. See perlop and keep in mind that Perl has useful ideas about what constitutes true and false. undef, '', '0' and 0 are all false. Consider:

print undef || "undef is false", "\n"; print 0 || "0 is false", "\n"; print '' || "'' is false", "\n"; print '0' || "'0' is false", "\n"; print '0xxx' || "'0xxx' is false", "\n"; print 'false' || "'0xxx' is false", "\n"; print '1' || "'0xxx' is false", "\n";

Prints:

undef is false 0 is false '' is false '0' is false 0xxx false 1

Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^6: Problems with HOHOH modification
by kyle (Abbot) on Feb 13, 2008 at 20:27 UTC