Database Reference
In-Depth Information
$ cat args.pl
#!/usr/bin/perl
print "Script name: $0\n";
$ chmod +x args.pl
$ ./args.pl
Script name: ./args.pl
This works without problems but is not portable. On another system, the Perl interpreter
might reside in the directory /usr/local/bin/perl instead of /usr/bin/perl . The Perl script
would not run on such a system.
$ ./args.pl
: bad interpreter: No such file or directory
A better approach is to employ a level of indirection by first using the UNIX command env ,
which is located in the directory /usr/bin on all UNIX systems, as the interpreter executable. It
has the capability to set environment variables based on command line arguments and to run
other programs. The environment variable PATH is considered when env attempts to locate the
program to run. Thus, the code of the script need not be modified to run on other systems.
Only the PATH variable must contain the directory where the Perl interpreter resides.
$ cat args.pl
#!/usr/bin/env perl
print "Script name: $0
$ ./args.pl
Script name: ./args.pl
Transparently Running Perl Programs
on Windows
Matters are slightly more complicated on Windows. But then again, Windows offers the option
to omit the extension .pl commonly used for Perl programs. You win some, you lose some, as
they say. Here is the deal. First of all, you define a new file type to Windows and tell it which
executable is responsible for the file type. Obviously the executable is perl.exe . Note that
Windows requires the absolute path to the executable. The environment variable PATH is not
considered for searching the executable, though environment variables may be used within
the definition. The command FTYPE is used for defining the file type. In the following code
example I use the file type PerlProgram :
C:> FTYPE PerlProgram="C:\oracle\product\db10.2\perl\5.8.3\bin\MSWin32-x86-multi-thr
ead\perl.exe" %1 %*
PerlProgram="C:\oracle\product\db10.2\perl\5.8.3\bin\MSWin32-x86-multi-thread\perl.e
xe" %1 %*
Here, the installation of Oracle10 g is in C:\oracle\product\db10.2 . Assuming you have
defined ORACLE_HOME as an environment variable, you may also call FTYPE like this:
 
Search WWH ::




Custom Search