perl package directories - what if the script is diff DIR to the one contain *.pm?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl package directories - what if the script is diff DIR to the one contain *.pm?
# 1  
Old 11-23-2004
perl package directories - what if the script is diff DIR to the one contain *.pm?

Hi there,

say the package is in the ~/ and it's ~/packageFoo.pm

I can use usePackage.pl in ~/ (~/usePackage.pl).

Now, if I move it to ~/subDIR/usePackage.pl, the script won't work because it's not in the same DIR with packageFoo.pm

How can i fix it?

Thanks

Gusla
# 2  
Old 11-23-2004
Two ways.

Just amend the include path at the top of your script, i.e. @INC

e.g.

Code:
@INC = ('..', @INC);

Maybe to cause it to take effect early (before execution) by

Code:
BEGIN {
	@INC = ('..', @INC);
}

which is essentially the same as the Perl pragma "use lib" :

e.g.

Code:
use lib '..';

More information:
http://theoryx5.uwinnipeg.ca/CPAN/perl/lib/lib.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing two directories with diff

Hi all, I have 2 directories on two different servers. I am trying to find out what is missing from directory X and what is missing from directory Y. they should both have the same exact files in them. I understand some files may be missing from both directories on each server. I am not sure... (8 Replies)
Discussion started by: jeffs42885
8 Replies

2. Shell Programming and Scripting

Comparision of two directories of diff servers

Hi All, I have transferred some directory structures from server1 to server2 by creating a tar files. Now i need to cross check whether I transferred entire structures or not. Is there any command to check this on each individual server. Thanks (2 Replies)
Discussion started by: nag_sathi
2 Replies

3. Shell Programming and Scripting

Need a perl script similiar to grep -r 'word' /path/to/dir"

Hi , i am looking for a perl script to grep for a string in all files inside a directory . bash command . grep -r 'word' /path/to/dir Thanks, Nvil (3 Replies)
Discussion started by: nevil
3 Replies

4. Shell Programming and Scripting

Perl Script not working on all directories

Hi Folks, I have a script that I am using. The files are in Directory c:\files\change\options In that directory I have many other sub folders like R1 R2 R5 E4 etc... When I run this script in windows, It looks like its just changing the first folder R1 and not the rest. Can I get an... (6 Replies)
Discussion started by: richsark
6 Replies

5. Shell Programming and Scripting

diff script to copy files to other dir when not exists

I have two directories that are mostly the same: dir1 dir2 Is there an easy way to take the output of diff and copy files from dir1 that do not exist in dir2 - but copy them to the same path (many nested directories). am only trying to copy files in dir1 that do not exist in dir2. ... (5 Replies)
Discussion started by: jvsrvcs
5 Replies

6. UNIX for Dummies Questions & Answers

Copying dir (and sub dir) file names from ftp server to txt file in diff server

Hey all, i want to copy only the file names from an ftp server (directory and all sub directory) to a text file in another server (non ftp), i.e. i want to recursively move through directories and copy only the names to a text file. any help is appreciated...thank you in advance (1 Reply)
Discussion started by: deking
1 Replies

7. Shell Programming and Scripting

How to search through directories and sub dir

Im working on a project that basically imitates the find and whereis commands. The program will take in a file name or regular expression and, starting with the current directory search downwards and match any files with that pattern and prints the path name. I don't understand how to do this... (5 Replies)
Discussion started by: new2C
5 Replies

8. UNIX for Dummies Questions & Answers

Using diff on files in different directories

Hi, I want to be able to compare two different files in two different directories. I have a development server set up on one domain and a live server set up on another.....I need to be able to compare files on these two servers. Any ideas? (2 Replies)
Discussion started by: elduderino
2 Replies

9. Shell Programming and Scripting

compare 2 coloum of 2 diff files using perl script

Hi, i am new to perl scripting.. i am still learing it.. i am asked to write a perl script which should compare 2 coloums of 2 different files. if those 2 coloumn are same the script should store the both the lines in 2 diff files. these are files, file 1: 21767016 226112 char 19136520... (3 Replies)
Discussion started by: vasuki
3 Replies

10. UNIX for Dummies Questions & Answers

perform diff between 2 directories

Hello all i wander what is the best way to make diff between 2 directories and perform diff of 2 kinds the first is the names of the files on each directory , and the second diff is between the content of each file and the corresponding file and the second dir. Thanks for the help (5 Replies)
Discussion started by: umen
5 Replies
Login or Register to Ask a Question