FAQ

On Mon, Feb 8, 2010 at 6:19 PM, Uri Guttman wrote:

"7" == 7 <7stud.7stud@gmail.com> writes:
7> if (defined $var && ($var eq '' || $var eq '0')) {

7> #code

7> }

7> to handle cases where $var = undef. undef acts like it is a blank
7> string when used as a string.

blah..

unless( $var ) {

is all you need for that situation. you are already testing three of the
four allowed false values. and the numeric 0 would be covered under the
eq '0' test anyhow.

newbies should be taught perl's boolean false values early on.

Because unless and until statements are harder to maintain, NO ONE should
use them--least of all beginners.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 12 of 18 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedFeb 9, '10 at 12:39a
activeFeb 9, '10 at 7:24a
posts18
users4
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase