On 9/27/02 9:12 AM, "Tim Grant" <[EMAIL PROTECTED]> wrote:
> A philosophy question... > > For no particular reason, I keep my Perl scripts in user space > (/Users/grant/bin/perl). The scripts work with directories elsewhere in my > user space. These scripts get deployed to other machines and are run by > different users. > > Is there a good way to tell Perl about the user space? Or is it > easier/better just to use the system space? > > Regards, > Tim Grant > ----------------- > Here's an example of the mess I've made for myself: > > #!/opt/perl/bin/perl -w > > use lib qw(../../lib); # ~/bin/perl/lib > use HOMEMADE_MODULE; > # Relative path breaks if script moved/run from another directory > > > my $path = \qq"/users/grant/data/vendor1"; > # Absolute path needs to be changed if script moved to different computer I'm not entirely sure which problem you are trying to solve, in that the first example will fail both when the script is moved (because ../../lib doesn't exist) but will also fail when left in place but run from a different directory (because the relative path is relative to current directory and not script path). Nevertheless I'll jump in and say that FindBin is your best option for this stuff unless you want to install to the core site_perl directory. Most of my scripts are packaged with their lib dir alongside and start with: use FindBin; use lib $FindBin::Bin . "lib"; Which covers the run from a different directory case and makes the application an easy drag and drop for most users. Finding your data dirs is probably harder, unless you can guarantee they are in the same location of each user's home dir. Or if its shared machine-wide data maybe put it in /var? HTH, Alex -- Alex Harper [EMAIL PROTECTED] "Eternity is a terrible thought. I mean, where's it going to end?" - Tom Stoppard