Reputation: 1
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.
foobar
is defined in /usr/lib/foo/bar.pm
, so I can't narrow use lib
down any further.foobar
doesn't rely on any other files in the library - If I shift every other file out of /usr/lib/foo/
, it executes at least 10x faster, so I'm just trying avoid that. I do expect bar.pm to change over time, so making my own separate library isn't ideal.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
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