What/where do I set path for perl

I currently have to type perl in front of a perl script in order to get it to execute. What do I have to do so I don't have to type perl in front of the script name? An addition to my .profile?????
894359Asked:
Who is Participating?
 
Thunder27Connect With a Mentor Commented:
1) Make sure your script identifies itself to Unix as a Perl script by having this as its first line:  #!/usr/bin/perl
2) Turn on the Unix "execute" permission for your script file by typing this command at the Unix prompt:  $ chmod +x yourscript.pl
3) Run your script by typing its filename.
0
 
sykknCommented:
I would like to extend Thunder27's #3 ...

run your script using either ./scriptname.pl if in the script is in the current working directory or /path/to/scriptname (full path) ... and possible relative path, but and explanation of that is beyond the scope of this question.

Hope that helps.
0
 
holliCommented:
in a windows/dos environment you can use the following trick:

name this file perlscript.bat:

@ECHO OFF
IF EXIST %0 perl -x %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
IF EXIST %0 GOTO BATCHEND
perl -x %0.BAT %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO BATCHEND

#!perl
print "hello from batched perl!";

__END__
:BATCHEND

so typing
perlscript or perlscript.bat will both print "hello from batched perl!"

using nt/2000 and activeperl you can also start a script by typing its full name (including the .pl extension), followed by the arguments:

foo.pl arg1 arg2 ...


holli
0
 
Thunder27Commented:
Along the same lines as holli mentioned (in the UNIX/LINUX environment though), you can create a shell script to run the perl script:

file domyperl.sh:
cd /usr2/db/backup_scripts
perl myscript.pl >>logs/errs.log 2>&1

Save it (i.e., domyperl.sh).
Chmod to 700


then run from the command line as ./domyperl.sh
0
 
894359Author Commented:
It was my stupid mistake!
0
All Courses

From novice to tech pro — start learning today.