[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Stumper



On Fri, Mar 16, 2001 at 12:15:53AM +0000, Michael G Schwern wrote:
> I'm stumped.  I want to know how many times a certain function is
> called inside a lexical block without actually running that block of
> code.  For example:
> 
>         foo {
>             bar();
>             bar();
>             bar();
>         };
> 
> Assuming foo() is prototyped (&), how could it know that bar() is
> called three times in that block without actually running it?

Is it that you don't want to run the block at all, or just not bar()?
In that case, you could rename &bar, replacing it by a sub that adds
one to a counter, run the block, rename the renamed &bar back and
report the counter.

Of course, if it depends on run-time effects, you are unable to find
out how often it's called anyway, since that requires you to solve the
halting problem.


Abigail

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe