use of undef
Tom Phoenix
rootbeer at redcat.com
Wed Jun 13 10:27:13 CDT 2001
On Wed, 13 Jun 2001, Erik Hollensbe wrote:
> austin already replied about defined(), but you may find that something
> along these lines would solve your problem much cleaner than a GOTO:
GOTO? Who is using GOTO?
> @array(0..2, ,undef);
I think you omitted an equals sign here.
> $count = 0; # not needed unless use strict
No, if you have 'use strict' enabled, you would need to declare these
variables; that line wouldn't accomplish that. If you have warnings
enabled, you would need to initialize $count before using it as an array
index, though; that's probably what you were thinking of.
> while(1) { defined($array[$count]) ? $count++ : last };
Real Perl programmers don't use subscripts. :-) It's almost certainly more
efficient to use a foreach loop on the array. Also, I prefer not to use
the ?: operator as a control structure, since it is harder to understand
(and potentially less efficient) than a simple if/else would be.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
----- End forwarded message -----
TIMTOWTDI
More information about the Pdx-pm-list
mailing list