0

Here's my project:

assembler/ asm.pl # Main entry point instructions.pm support.pm build.sh ---- assembler/asm.pl ---- ... use instructions; ... ---- assembler/instructions.pm ---- ... use support; ... 

I wish for build.sh to contain a line like:

perl assembler/asm.pl $1 

When asm.pl tries to use the related modules, it can't find them. This line works, but feels filthy and shameful:

cd assembler; perl asm.pl ../$1; cd .. 

What is the correct way to execute asm.pl? I wish to execute the program located anywhere on the file system directly from any other arbitrary location, e.g.

$ cd /some/dumb/path $ /path/to/the/project/build.sh /another/goofy/path.asm 
1
  • 1
    Does it work for your use case if you use the -I option, e.g. perl -I assembler ? Commented Nov 29, 2012 at 23:52

1 Answer 1

4

I believe the problem is that perl is trying to find the libraries relative to the path you're executing from. That's why running cd first fixes it. Your other option is to tell perl where it might find the files. You can do this using the PERL5LIB environmental variable or with the -I switch. This should do it:

perl -I./assmbler/ assembler/asm.pl $1 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.