Finding "Undefined subroutines" before running program

H

Hal Vaughan

I had a module I was using as a common library for a number of programs. It
kept getting bigger and bigger until even the smallest program that used it
took a long time to load, so I split it up into a number of smaller
modules. Now I have some programs that I have to keep stable, so they
still use the oversized module. I'd like to be able to find some way to
scan these programs, and see if any subroutines they they call are located
only in the old module.

I can't think of any way to do this. I figured I could remove the "use"
statement that calls the old, oversized library, and run the programs to
see if I get any "Undefined subroutine errors", but it'll be difficult to
run all the variations to make sure it goes through all the variations of
the conditional branches.

Is there any way to find out if a program (and the modules it calls) are
undefined, or to find out where each called subroutine is (whether it's in
the program, or what module it's in)?

I'm not quite sure what terms to use to look this up. I've got a feeling
this falls under some category or term I don't expect it to.

Thanks!

Hal
 
A

Anno Siegel

Hal Vaughan said:
I had a module I was using as a common library for a number of programs. It
kept getting bigger and bigger until even the smallest program that used it
took a long time to load, so I split it up into a number of smaller
modules. Now I have some programs that I have to keep stable, so they
still use the oversized module. I'd like to be able to find some way to
scan these programs, and see if any subroutines they they call are located
only in the old module.

I can't think of any way to do this. I figured I could remove the "use"
statement that calls the old, oversized library, and run the programs to
see if I get any "Undefined subroutine errors", but it'll be difficult to
run all the variations to make sure it goes through all the variations of
the conditional branches.

Is there any way to find out if a program (and the modules it calls) are
undefined, or to find out where each called subroutine is (whether it's in
the program, or what module it's in)?

None that I know of.
I'm not quite sure what terms to use to look this up. I've got a feeling
this falls under some category or term I don't expect it to.

The problem is related to that of test coverage. There may be modules
in that category that help with your problem.

You could also use the "autouse" pragma so that all functions that are
not loaded from elsewhere will eventually be loaded from the big library.
See perldoc autouse for how to do that and for possible problems.
Modify the library so that it logs each time it is loaded.

That way the program remains runnable, but each time it uses the big
library you will know and can eliminate the case. After a sufficient
number of runs you may be convinced you have them all. (More likely,
you'll just leave it as it is, but the time-consuming loads won't
happen anymore.)

Anno
 
S

Sherm Pendley

Hal said:
I had a module

You might want to have a look at "perldoc AutoLoader" and "perldoc
AutoSplit". Together, they provide the means to load individual
subroutines on demand, instead of loading them all at startup.

sherm--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top