in reply to Efficiency and Functions in loops

Perl doesn't do it automatically, but you can very easily cache it yourself.
my %cache; while ($foo < $cache{$bar} ||= ReallyComplexFunction($bar)) { doStuff(); }

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re: Efficiency and Functions in loops
by suaveant (Parson) on Oct 11, 2001 at 22:17 UTC
    There is one caveat to your way, dragonchild, and that is if ReallyComplexFunction returns a 0 or '', or even undef, the ||= will see that as false and re-run the routine... may not be an issue, though...

                    - Ant
                    - Some of my best work - Fish Dinner