On Jul 29, Bob Showalter said: >Bob Showalter wrote: >> ... >> A more efficient iterative approach using a numeric equality test >> would be: >> >> sub checkNumber { >> $_[0] == $_ && return 1 for @numbers; >> return; >> } >> >> This returns 1 for a match and undef for no match. > >Heck, you can even leave off the last "return" there. That will return 1 for >a match and '' for no match (i.e. the result of the last failed == test), >which are still Perl "true" and "false" values.
Actually, the return value will be '' from the end of the for() loop. When a for() loop ends, Perl internally evaluates something, which returns a value of "" as far as Perl's outsides are concerned, which signifies the end of the for-loop's list. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]