On Mar 26, 2007, at 7:32 PM, Tom Phoenix wrote:

On 3/26/07, Mike Lesser <[EMAIL PROTECTED]> wrote:

Hi all. First time using subroutines in external files. I've had some
sporadic success with some simple libs (not modules), but can't seem
to get consistent results.

What do you mean by "sporadic success"? Does something work only on
some invocations of your program? Once you can get it to work, doesn't
it keep working?

I've been able to use FindBin as described in the alpaca book to load a
single file. When I try to use another - almost identical - file, it fails.
I've tried FindLib-again as well as pretty much everything I've seen
online. There's a level of


use FindBin qw($Bin);
use lib "$Bin/Libs";

'use lib' doesn't load your library files; it just tells Perl where to
find them. You still need to load them (either with require or use).
You could put code like this after those two lines; the BEGIN block
ensures that the external subroutines are compiled before the
following code begins compilation.

 BEGIN {
   require "first.pl";
   require "another.pl";
   require "one_more.pl";
 }


It works! Thanks. That's what I didn't glean from the books. I think the
stuff I've seen online is either outdated or simply unsuited to multiple
files. Makes sense, since modules is the way to go, apparently.

yeah, they're executable, and yeah, I've tried several approaches.

Modules and libraries don't normally need to be marked as executable.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to