in reply to Check if one of the array elements is not empty
Just for clarification, there is a difference between an empty string("") and a string with one space(" "):
use strict; use warnings; use 5.010; my @array=("", "jim"," "); foreach my $str (@array) { if ($str) { say "perl considers the string: -->$str<-- to be true."; }else { say "perl considers the string: -->$str<-- to be false."; } } output: perl considers the string: --><-- to be false. perl considers the string: -->jim<-- to be true. perl considers the string: --> <-- to be true.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check if one of the array elements is not empty
by desemondo (Hermit) on Nov 11, 2009 at 02:37 UTC |