in reply to Re: Dynamic Tk buttons from init file
in thread Dynamic Tk buttons from init file

Thanks rjray. Good idea. I think I'll steal it!

For some reason I could not get the Plugin::Print::run to work.

Test file "foo.pl"

#!/usr/local/bin/perl -w Plugin::Print::run;
Then in the Plugin directory I have Print.pm
package Plugin::Print; sub run { print "Got print run!\n" } 1;
When I run this I get Undefined subroutine &Plugin::Print::run called at foo.pl line 3.

I expermented some and found that I could do this Test file "foo.pl"

#!/usr/local/bin/perl -w use Plugin; Plugin::Print::run; Plugin::Edit::run;
Then in Plugin.pm in same directory
package Plugin::Print; sub run { print "Got print run!\n" } package Plugin::Edit; sub run { print "Got print run!\n" } 1;
This works well enough but I'm curious why the first one didn't work?

TunesMan

Replies are listed 'Best First'.
Re: Re: Re: Dynamic Tk buttons from init file
by rjray (Chaplain) on Mar 20, 2003 at 01:19 UTC

    For one thing, your first example doesn't seem to "use" the module before trying to call the routine.

    Another thing to watch for, is that if you plan on saying "use Plugin::Print", then Print.pm will have to be in a directory called "Plugin", and that directory in your search path. But there are other ways of reading in the code, besides "use" and "require".

    --rjray