At 01:09 -0500 04/01/2011, George Worroll wrote:
On 1/4/11 12:33 AM, Sunita Rani Pradhan wrote:
Perl script works without the first line ( perl Interpreter
: #! /usr/bin/perl) . What is the real use of this line ? This line does
not through any error on Windows where , this path does not exist .
On Unix, it allows you to run your script with just the scripts
filename rather than running the interpreter and passing the
filename as an argument. "./myscript" instead of "perl myscript".
On Windows, that line is just a comment...
On UNIX/ Mac OS X it also gives you the option of using a variety of
perl installations. For example the Apple installation of Perl is
made in /usr/bin but the default installation is in /usr/local/bin
and other programs might make further installations in, say,
/opt/local/bin/...
...so if I run this script:
#!/usr/bin/perl
use strict;
print "Perl Version: $^V\n";
print "\...@inc:\n" . join $/, @INC;
I will get this:
Perl Version: v5.10.0
@INC:
/Users/jd
/Library/Perl/Updates/5.10.0/darwin-thread-multi-2level
/Library/Perl/Updates/5.10.0
/System/Library/Perl/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/5.10.0
/Library/Perl/5.10.0/darwin-thread-multi-2level
/Library/Perl/5.10.0
/Network/Library/Perl/5.10.0/darwin-thread-multi-2level
/Network/Library/Perl/5.10.0
/Network/Library/Perl
/System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.10.0
.
but if I install a later version and want to bypass the Apple (or
other) installation altogether then I can change the shebang as
follows:
#!/usr/local/bin/perl
use strict;
print "Perl Version: $^V\n";
print "\...@inc:\n" . join $/, @INC;
and get:
Perl Version: v5.12.2
@INC:
/Users/jd
/usr/local/lib/perl5/site_perl/5.12.2/darwin-2level
/usr/local/lib/perl5/site_perl/5.12.2
/usr/local/lib/perl5/5.12.2/darwin-2level
/usr/local/lib/perl5/5.12.2
.
JD
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/