user18804004
user18804004

Reputation: 1

How do I use a single .pm file in Perl?

My perl script is very time-sensitive, and needs a single function, foobar, from another library. Currently, the script does this with

use lib qw(/usr/lib/foo/);

Unfortunately, this library is rather obtuse, this single use line imports hundreds of files and subdirectories and takes up about almost a second of processing time.

What's the cleanest way to pull in this .pm file and nothing else? Ideally into the main namespace so I can call the function directly and don't need to break coding-style. In an ideal world I'd just be able to use use lib qw(/usr/lib/foo/bar.pm), but it dun' like that.

Upvotes: 0

Views: 439

Answers (1)

ikegami
ikegami

Reputation: 386396

lib doesn't pull anything in. bar is the one pulling in all those other modules (directly or indirectly). If you want to load bar but not the others, you'll have to change bar.

Upvotes: 3

Related Questions