in reply to Variable to point to library?

The problem is that 'use' statements get wrapped in BEGIN blocks, so $pathtolib isn't set by the time 'use lib' needs it. Here's how you can accomplish what you're looking for:

#!/usr/bin/perl my $pathtolib; BEGIN { $pathtolib = &opentextfile; } # opentextfile must be defined b +efore this line use lib $pathtolib;

or even:

#!/usr/bin/perl # define opentextfile somehow use lib &opentextfile;