On Feb 10, Jeff 'japhy' Pinyan said:
>On Feb 10, James Edward Gray II said:
>
>>I said I cannot fix the grep() version. I'm just not that cool.
>
>I guess I'm cooler than you. ;)
>
> sub find {
> my $wanted = shift;
> my $found = 0;
> { grep $_ eq $wanted && ++$found && last, @_ }
> return $found;
> }
Or even:
sub find {
my $wanted = shift;
grep $_ eq $wanted && return(1), @_;
return 0;
}
--
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]
<http://learn.perl.org/> <http://learn.perl.org/first-response>