From: "SSC_perl" <p...@surfshopcart.com>

I'm in the process of moving certain files of the SurfShop script into a 
sub-directory to clean up the main directory and would like to know the best 
way for the script to find these files.

I was using this method:

use FindBin qw($Bin);
use lib "$Bin/../ss_files";

which worked for me, but I read somewhere that FindBin can break in certain 
situations.

I have never met a situation in which FindBin was not working. But I haven't 
met all possible situations in the world, so... :-)
So this method is very good.


> So I tried the following:
use lib "ss_files";

This also works, but iirc, I read that it won't work across all platforms.  Is 
that correct?


This method also works, but to be equivalent with the first method it should 
have been:

use lib "../ss_files";

This second method has a big limitation though. If The current directory when 
you run the script is the directory in which is place the script, then it will 
work.
If you change the current directory to be another directory, like /home/user 
for example, it won't work, because it will search for modules in 
/home/ss_files.

Using FindBin will always get the path to the directory in which is placed the 
script you run, and then the line "use lib" will set the path of modules 
starting from that path and not from the current directory.


Is one of these methods better than the other, or is there another way that I 
haven't found yet?


The first method is better because it will work even if you change the current 
directory. And you can run the scripts from a cron job for example.
Octavian


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to