2008/5/1 Gavin Ford <[EMAIL PROTECTED]>: > I'm wondering if I'm making things over complicated for myself.
Common enough :) > I have a few subroutines I reuse in a few scripts, so I moved them to another > file in the same directory and link them into each script with something > like: > > use FindBin '$Bin'; > require "$Bin/lib-rf-iplayer.pl"; > > I had been entering the full path on the require line, but this was a bit > rubbish as it needed to be tweaked for different machines or users. > > But this still feels like I'm going a step too far. Not just too far, but in the wrong direction. Why not spend a very small ammount of time to turn it into a module. Then you can just 'use lib-rf-iplayer;' at the top of each script and it will just work. > Is there a simpler way to require a file relative to the script instead of > relative to the working directory? That's probably the wrong question :) But setting PERL5_LIB is likely to helpful whether going the right way or the wrong way - so http://sial.org/blog/2006/08/customize_inc_via_perl5lib.html is worth a read. A. -- http://www.aarontrevena.co.uk LAMP System Integration, Development and Hosting _______________________________________________ BristolBathPM mailing list [email protected] http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm
