in reply to variable sees it, array doesn't - stumped!
The bug is here:
# check if the field's not null, if not, array it if ($photo != "") {push(@array, $photo);}
You're using "!=" to compare strings, but it only compares numbers. See perlop for the gory details. You should be using "ne" instead, though you might also want to check if it's defined.
What happens on that line is that a string in $photo is treated as a number, which will be zero unless it starts with some other digits. That number is then compared to the number that "" is translated to (zero). So you have "if ( 0 != 0 )". As such, @array is still empty by the time you get down to the print.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: variable sees it, array doesn't - stumped!
by shrdlu (Novice) on Dec 31, 2008 at 17:03 UTC |