use of undef

Tom Keller kellert at ohsu.edu
Mon Jun 11 16:31:36 CDT 2001


Hi all,
I'm confused about the use of undef.
I want to count the number of elements in a list until the first undefined value.
I tried this:
@array = (0, 1, 2,  , "next", "group");
ELEMENTS: foreach $element (@array) {
      $count++;
      last ELEMENTS if $element eq undef;
}
It gives me the correct count, 3, and leaves the loop correctly, but I get a warning for each element.
What am I missing?

Thanks,
Tom Keller
TIMTOWTDI



More information about the Pdx-pm-list mailing list