in reply to any built in function to take out null arrays elements?
But perhaps you are thinking of an array containing empty elements: @array_with_empties = ('ONE', 'TWO', '', 'FOUR');
$array_with_empties[2]) is empty, but exists($array_with_empties[2]); will return a TRUE value! Indeed the array element exists, but is empty.
To check if this array-element is empty, simply test it against the empty element '' or against undef.
And to answer your question: you will always need a loop (explicit or implicit) to check for such elements.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: any built in function to take out null arrays elements?
by chromatic (Archbishop) on Sep 21, 2007 at 08:39 UTC | |
by CountZero (Bishop) on Sep 21, 2007 at 08:43 UTC |