[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [FWP] Something like "grepfirst"
>
>> For a 11 less bytes, eleminate the recursion:
>>
>> sub first_existing_dir {
>> d: my $d=shift or die;
>> -d $d ? $d : goto d
>> }
>
> Oh, nice! This is even better:
> replace recursion with Perl's highly magical goto SUB:
>
> sub first_existing_dir {
> my $d=shift or die;
> -d $d ? $d : goto &first_existing_dir
> }
>
> Can anyone on this list tell me if Perl does tail recursion elimination?
> I don't think it does; but it provides a way for you to eliminate it
> explicitly. Shweet.
I got rejected on comp.lang.perl.moderated; but
Stephen Zander <gibreel@pobox.com> told me about:
for (qw(dir0 dir1 /tmp)) { -d && print && last; }
So, it's not a total loss... ;)
Thanx Stephen!
HAGD!
-Sneex- :]
==== Want to unsubscribe from Fun With Perl? Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
==== unsubscribe