in reply to Array condition always true
my @header_present=" "; #clearing the data here
This places one element into @header_present, which is a string consisting of a single space. Arrays are true if they contain at least one item, that's the case after this piece of code.
The right thing would be not to assign anything; my @var automatically creates a new, fresh, empty array.
If you want to clear an array later on, you can write
# recommended: @var = (); # or a bit more excotic: $#var = -1;
You can read more about that in perldata.
You would do well to adapt a consistent code indenting style. See perlstyle for example.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array condition always true
by Anonymous Monk on Mar 20, 2011 at 11:36 UTC | |
by GrandFather (Saint) on Mar 20, 2011 at 19:42 UTC |