Re: 1st line of perl script
I think there is no error thrown by Windows (or any other architecture) because this line is never compiled because of the # in front which signifies the line as comments. On Tue, 04 Jan 2011 00:33:18 -0500, Sunita Rani Pradhan sunita.prad...@altair.com wrote: Hi All 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 . Why is it so ? Could anybody explain it clearly? Thanks Sunita -- Using Opera's revolutionary email client: http://www.opera.com/mail/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: 1st line of perl script
We have -w option for warnings which we specify with the 1st line . How does it work on windows ? -Sunita -Original Message- From: Donald Calloway [mailto:donald.callo...@gmail.com] Sent: Sunday, January 09, 2011 6:42 PM To: beginners@perl.org Subject: Re: 1st line of perl script I think there is no error thrown by Windows (or any other architecture) because this line is never compiled because of the # in front which signifies the line as comments. On Tue, 04 Jan 2011 00:33:18 -0500, Sunita Rani Pradhan sunita.prad...@altair.com wrote: Hi All 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 . Why is it so ? Could anybody explain it clearly? Thanks Sunita -- Using Opera's revolutionary email client: http://www.opera.com/mail/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
Maybe you can use use warnings; for this ... Best regards Christian Am 10.01.11 13:49 schrieb Sunita Rani Pradhan unter sunita.prad...@altair.com: We have -w option for warnings which we specify with the 1st line . How does it work on windows ? -Sunita -Original Message- From: Donald Calloway [mailto:donald.callo...@gmail.com] Sent: Sunday, January 09, 2011 6:42 PM To: beginners@perl.org Subject: Re: 1st line of perl script I think there is no error thrown by Windows (or any other architecture) because this line is never compiled because of the # in front which signifies the line as comments. On Tue, 04 Jan 2011 00:33:18 -0500, Sunita Rani Pradhan sunita.prad...@altair.com wrote: Hi All 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 . Why is it so ? Could anybody explain it clearly? Thanks Sunita -- Using Opera's revolutionary email client: http://www.opera.com/mail/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: 1st line of perl script
Yes I can use that . Does this -w option works on windows or not ? -Original Message- From: Christian Marquardt [mailto:christian.marqua...@trivadis.com] Sent: Monday, January 10, 2011 6:22 PM To: Sunita Rani Pradhan; Donald Calloway; beginners@perl.org Subject: Re: 1st line of perl script Maybe you can use use warnings; for this ... Best regards Christian Am 10.01.11 13:49 schrieb Sunita Rani Pradhan unter sunita.prad...@altair.com: We have -w option for warnings which we specify with the 1st line . How does it work on windows ? -Sunita -Original Message- From: Donald Calloway [mailto:donald.callo...@gmail.com] Sent: Sunday, January 09, 2011 6:42 PM To: beginners@perl.org Subject: Re: 1st line of perl script I think there is no error thrown by Windows (or any other architecture) because this line is never compiled because of the # in front which signifies the line as comments. On Tue, 04 Jan 2011 00:33:18 -0500, Sunita Rani Pradhan sunita.prad...@altair.com wrote: Hi All 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 . Why is it so ? Could anybody explain it clearly? Thanks Sunita -- Using Opera's revolutionary email client: http://www.opera.com/mail/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On 11-01-10 10:21 AM, Sunita Rani Pradhan wrote: Yes I can use that . Does this -w option works on windows or not ? I do believe so but if you `use warnings;` you can turn it off. You can't do that with -w. use warnings; { no warnings; # some code } -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On Mon, Jan 10, 2011 at 10:32 AM, Shawn H Corey shawnhco...@gmail.com wrote: I do believe so but if you `use warnings;` you can turn it off. You can't do that with -w. I just tested with Strawberry Perl v5.12.1 in Windows XP with the following code: #!/usr/bin/perl -w my @a; my $b = @a[0]; __END__ When run, I get: Scalar value @a[0] better written as $a[0] at test.pl line 4. So yes, it does seem to work, but I think that 'use warnings;' is best practice anyway, as Shawn pointed out. -- Brandon McCaig http://www.bamccaig.com bamcc...@gmail.com V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software http://www.castopulence.org/ bamcc...@castopulence.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: 1st line of perl script
Yes I agree . Then I am coming back to my 1st question . This path does not exist on windows /usr/bin/perl , how it works ? Thanks Sunita -Original Message- From: Brandon McCaig [mailto:bamcc...@gmail.com] Sent: Monday, January 10, 2011 9:14 PM To: Shawn H Corey Cc: beginners@perl.org Subject: Re: 1st line of perl script On Mon, Jan 10, 2011 at 10:32 AM, Shawn H Corey shawnhco...@gmail.com wrote: I do believe so but if you `use warnings;` you can turn it off. You can't do that with -w. I just tested with Strawberry Perl v5.12.1 in Windows XP with the following code: #!/usr/bin/perl -w my @a; my $b = @a[0]; __END__ When run, I get: Scalar value @a[0] better written as $a[0] at test.pl line 4. So yes, it does seem to work, but I think that 'use warnings;' is best practice anyway, as Shawn pointed out. -- Brandon McCaig http://www.bamccaig.com bamcc...@gmail.com V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software http://www.castopulence.org/ bamcc...@castopulence.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: 1st line of perl script
It doesn't, the line starts with a '#' so it is ignored. You have to tell MS-Windows to associate .pl files with perl.exe. Then the OS does what #! was supposed to. But it will always use the same copy of perl.exe, so you don't get the ability to use different releases for different scripts. Bob McConnell -Original Message- From: Sunita Rani Pradhan [mailto:sunita.prad...@altair.com] Sent: Monday, January 10, 2011 10:58 AM To: Brandon McCaig; Shawn H Corey Cc: beginners@perl.org Subject: RE: 1st line of perl script Yes I agree . Then I am coming back to my 1st question . This path does not exist on windows /usr/bin/perl , how it works ? Thanks Sunita -Original Message- From: Brandon McCaig [mailto:bamcc...@gmail.com] Sent: Monday, January 10, 2011 9:14 PM To: Shawn H Corey Cc: beginners@perl.org Subject: Re: 1st line of perl script On Mon, Jan 10, 2011 at 10:32 AM, Shawn H Corey shawnhco...@gmail.com wrote: I do believe so but if you `use warnings;` you can turn it off. You can't do that with -w. I just tested with Strawberry Perl v5.12.1 in Windows XP with the following code: #!/usr/bin/perl -w my @a; my $b = @a[0]; __END__ When run, I get: Scalar value @a[0] better written as $a[0] at test.pl line 4. So yes, it does seem to work, but I think that 'use warnings;' is best practice anyway, as Shawn pointed out. -- Brandon McCaig http://www.bamccaig.com bamcc...@gmail.com V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software http://www.castopulence.org/ bamcc...@castopulence.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On 11-01-10 10:57 AM, Sunita Rani Pradhan wrote: Yes I agree . Then I am coming back to my 1st question . This path does not exist on windows /usr/bin/perl , how it works ? It doesn't. At least, it doesn't if you start the script from Windows. What Windows does is look up the extension, *.pl, in the Registry and launch the program associated with it. When it starts, perl will check the first line for any switches (options in UNIX talk) and sets them. However, some web servers read the the shebang line and executes what it says. So, you should change any Perl CGIs to point to the perl program. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On Mon, Jan 10, 2011 at 11:07 AM, Shawn H Corey shawnhco...@gmail.com wrote: It doesn't. At least, it doesn't if you start the script from Windows. What Windows does is look up the extension, *.pl, in the Registry and launch the program associated with it. When it starts, perl will check the first line for any switches (options in UNIX talk) and sets them. However, some web servers read the the shebang line and executes what it says. So, you should change any Perl CGIs to point to the perl program. It isn't used to determine the interpreter on Windows, but it is still apparently always examined for command line options, regardless of platform. perldoc perlrun: The #! line is always examined for switches as the line is being parsed. Thus, if you’re on a machine that allows only one argument with the #! line, or worse, doesn’t even recognize the #! line, you still can get consistent switch behavior regardless of how Perl was invoked, even if -x was used to find the beginning of the program. I guess see `perldoc perlrun` for the full story. -- Brandon McCaig http://www.bamccaig.com bamcc...@gmail.com V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software http://www.castopulence.org/ bamcc...@castopulence.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On 11-01-10 11:15 AM, Brandon McCaig wrote: On Mon, Jan 10, 2011 at 11:07 AM, Shawn H Coreyshawnhco...@gmail.com wrote: However, some web servers read the the shebang line and executes what it says. So, you should change any Perl CGIs to point to the perl program. It isn't used to determine the interpreter on Windows, but it is still apparently always examined for command line options, regardless of platform. It isn't used if you start your scripts from Windows. But CGIs are started by the web server and some *do* look at the shebang line for the interpreter. For CGIs, make sure it has a valid program to run. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On Mon, Jan 10, 2011 at 11:21 AM, Shawn H Corey shawnhco...@gmail.com wrote: It isn't used if you start your scripts from Windows. It worked for me earlier: On Mon, Jan 10, 2011 at 10:43 AM, Brandon McCaig bamcc...@gmail.com wrote: I just tested with Strawberry Perl v5.12.1 in Windows XP with the following code: #!/usr/bin/perl -w my @a; my $b = @a[0]; __END__ When run, I get: Scalar value @a[0] better written as $a[0] at test.pl line 4. Invoked like: perl test.pl If I remove the -w from the shebang line then no warning is output. Unless I'm misunderstanding you... -- Brandon McCaig http://www.bamccaig.com bamcc...@gmail.com V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software http://www.castopulence.org/ bamcc...@castopulence.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: 1st line of perl script
And I repeat, it doesn't. Windows looks up the association you defined and then goes through the %PATH% in your environment looking for the first perl.exe it can find. It doesn't even read the file, but passes it as a parameter to perl.exe. At that point, it is up to the Perl interpreter to decide what to do with that first line. Bob McConnell -Original Message- From: Shawn H Corey [mailto:shawnhco...@gmail.com] Sent: Monday, January 10, 2011 11:08 AM To: beginners@perl.org Subject: Re: 1st line of perl script On 11-01-10 10:57 AM, Sunita Rani Pradhan wrote: Yes I agree . Then I am coming back to my 1st question . This path does not exist on windows /usr/bin/perl , how it works ? It doesn't. At least, it doesn't if you start the script from Windows. What Windows does is look up the extension, *.pl, in the Registry and launch the program associated with it. When it starts, perl will check the first line for any switches (options in UNIX talk) and sets them. However, some web servers read the the shebang line and executes what it says. So, you should change any Perl CGIs to point to the perl program. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On 11-01-10 11:34 AM, Bob McConnell wrote: And I repeat, it doesn't. Windows looks up the association you defined and then goes through the %PATH% in your environment looking for the first perl.exe it can find. It doesn't even read the file, but passes it as a parameter to perl.exe. At that point, it is up to the Perl interpreter to decide what to do with that first line. Except for some web servers; they do use the shebang line. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On 11-01-10 11:29 AM, Brandon McCaig wrote: Invoked like: perl test.pl If I remove the -w from the shebang line then no warning is output. Unless I'm misunderstanding you... It's the Perl interpreter that looks up the switches on the shebang line, not Windows. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On Mon, Jan 10, 2011 at 11:39 AM, Shawn H Corey shawnhco...@gmail.com wrote: It's the Perl interpreter that looks up the switches on the shebang line, not Windows. That's what I've been saying... -- Brandon McCaig http://www.bamccaig.com bamcc...@gmail.com V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software http://www.castopulence.org/ bamcc...@castopulence.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
From: Sunita Rani Pradhan sunita.prad...@altair.com We have -w option for warnings which we specify with the 1st line . How does it work on windows ? -Sunita Yes it works under Windows, but is recommended to not use it anymore. It is better to use (under any OS) instead: use warnings; Because later in some blocks of code if you'll want you will be able to use: no warnings; Of course, if you use the -w switch you will be still able to use no warnings; later, but it is not nice to begin by using -w then use no warnings;. Octavian -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
From: Shawn H Corey shawnhco...@gmail.com On 11-01-10 10:21 AM, Sunita Rani Pradhan wrote: Yes I can use that . Does this -w option works on windows or not ? I do believe so but if you `use warnings;` you can turn it off. You can't do that with -w. use warnings; { no warnings; # some code } Well, you can use: #!/usr/bin/perl -w { no warnings; print $ok; } It will work and it won't print the warning. The -w switch work, but the -W switch doesn't accept using no warnings;. But anyway, using use warnings; is recommended because it is cleaner to use use warnings; #and no warnings; then to use the -w switch and then eventually no warnings;. And the shebang line is not required in that case. For example, I haven't used it for years. Octavian -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
From: Bob McConnell r...@cbord.com It doesn't, the line starts with a '#' so it is ignored. You have to tell MS-Windows to associate .pl files with perl.exe. Then the OS does what #! was supposed to. But it will always use the same copy of perl.exe, so you don't get the ability to use different releases for different scripts. Bob McConnell Well, not exactly ignored. Here is a sample zzz.pl script: #!/usr/foo/bar -w print ok; Normally, if the shebang line would be really ignored, the program should run fine if the program is ran using: perl zzz.pl But the result is: E:\perl zzz.pl Can't exec /usr/foo/bar at zzz.pl line 1. Here is another sample script: #!/python27/python.exe import sys print(sys.copyright) And here I ran it with Perl: E:\perl zzz.pl E:\Copyright (c) 2000-2010 ActiveState Software Inc. Copyright (c) 2001-2010 Python Software Foundation. ... So even though the program is ran using the Perl interpreter, when it finds the shebang line, even under Windows, it executes the program using the interpreter found in that line, no matter it is not even Perl. But this is because Perl is smarter than Python for this thing. Here is a Perl code I put in the file zzz.py: #!/usr/bin/perl use CGI; print $CGI::VERSION; If I run it with Python, see what happends: E:\python zzz.py File zzz.py, line 2 use CGI; ^ SyntaxError: invalid syntax So it means that Python doesn't parse the shebang line and run the program with the program from it. Which thing is better? Perl is smarter, but it might be too smart and can create confusion for newbies. For example, the program will give an error if it will have a shebang line with a non-existent path like: #!/foo/bar/baz But it won't give an error when using a shebang like: #!/foo/sperlito/bar and neither when using one like: #!/foo/bar/baz/who/knows/others/perl/ok/zuzu because these paths contain the string perl (probably). So a shebang line like #!perl is enough if you want to use those switches. Octavian -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: 1st line of perl script
On Mon, Jan 10, 2011 at 11:21 AM, Shawn H Corey shawnhco...@gmail.com wrote: It isn't used if you start your scripts from Windows. It worked for me earlier: On Mon, Jan 10, 2011 at 10:43 AM, Brandon McCaig bamcc...@gmail.com wrote: I just tested with Strawberry Perl v5.12.1 in Windows XP with the following code: #!/usr/bin/perl -w my @a; my $b = @a[0]; __END__ When run, I get: Scalar value @a[0] better written as $a[0] at test.pl line 4. Invoked like: perl test.pl Invoking like this , you are specifying perl interpreter , is not it? Then why do we need 1st line ? Only test.pl also run this program . If I remove the -w from the shebang line then no warning is output. Unless I'm misunderstanding you... -- Brandon McCaig http://www.bamccaig.com bamcc...@gmail.com V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software http://www.castopulence.org/ bamcc...@castopulence.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
Hi Sunita, 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 . It is a shebang line which is only useful in Unix-like operating systems. In such systems, the shebang line should start in the first column of the first line. When such a script with its executable bit set is run by itself, the operating systems checks for the shebang line to see which interpreter should be used for executing the script. However, in Windows (and other non-Unix-like operating systems), the shebang is usually considered a comment and skipped. Instead of the shebang line, such systems depend on file extension associations or explicit invocation of the script using the interpreter. For more details, see: http://en.wikipedia.org/wiki/Shebang_(Unix) Regards, Alan Haggai Alavi. -- The difference makes the difference -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
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/
Re: 1st line of perl script
On 1/4/11 4:31 AM, John Delacour wrote: 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/... Very good point. The Perl team does at times intentionally break backwards compatability because they feel the old way was simply wrong. And it's always possible they'll do so accidentally, especially for more tricky ways of doing things. If you've got mission critical stuff running on Perl, keeping the old version around and accessible, at least for a while after the upgrade, is a good idea- and shebang makes it easy to support both as long as you need to. If you get to hacking the interpreter itself, you absolutely need a way to access the canonical version because at some point you will break the one you are hacking on. Hopefully you'll fix what you broke, but you don't want to be without Perl during that phase. Keeping the old version around and accessible- actually, that's probably a reasonable justification for using Windows file extensions other than .pl. Associate that to whichever version is your sites primary Perl installation, and associate something else(.prl for instance) to the secondary installation. Just make sure to have a standard for which extension calls which interpreter, or things will get confusing. Including a shebang on windows for documentation purposes, so people reading the code know what interpreter is supposed to get it, is a good idea even though it's not used by the system. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On Jan 4, 2011, at 12:09 AM, George Worroll wrote: I would, however, recommend that you use the #!/usr/bin/perl line even on Windows. It will make things a little easier if you have to move the script over to a Unix like system. It won't cause any problems in windows, it will just get skipped right over. Although I don't know if this works on Windows, I notice that nobody has mentioned... #!/usr/bin/env perl ... which invokes the perl that comes first in one's $PATH, making the script more portable, and also easing the management of having multiple Perls installed. It's discussed here: http://www.perlmonks.org/?node_id=716740 Chap -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On 11-01-04 02:56 PM, Chap Harrison wrote: Although I don't know if this works on Windows, I notice that nobody has mentioned... #!/usr/bin/env perl No, it doesn't. In the Windows Registry, the *.pl extension is linked to the perl program. Double-clicking on a *.pl file will run perl with it as an argument. It ignores the shebang line. Except... Some web servers read the shebang line to determine what program to run a CGI with. If you are running a server in Windows, make sure the shebang line of your CGIs points to a valid program. Example: !#C:\PERL\BIN\PERL.EXE -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
1st line of perl script
Hi All 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 . Why is it so ? Could anybody explain it clearly? Thanks Sunita
Re: 1st line of perl script
Thats called Sha-Bang header also called Magical Bytes. They come into picture when you do not specify the interpreter while executing the script. EG: ./my_script.pl (here no interpreter is specified i.e perl is missing) In this case, script uses the interpreter specified at sha-bang header. And now since you are specifying the interpreter on the prompt (perl my_script.pl) hence its not showing any error even on windows. Cheers, Parag On Mon, Jan 3, 2011 at 9:33 PM, Sunita Rani Pradhan sunita.prad...@altair.com wrote: Hi All 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 . Why is it so ? Could anybody explain it clearly? Thanks Sunita -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
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. Neither the operating system nor the interpreter does anything with it. To run a script with just the name, you need to use a file extension associated with the Perl interpreter. The standard extension is .pl, though in principle you could use something else. If you don't have corporate overlords forcing you to use something else, just use .pl. I would, however, recommend that you use the #!/usr/bin/perl line even on Windows. It will make things a little easier if you have to move the script over to a Unix like system. It won't cause any problems in windows, it will just get skipped right over. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
You can put any path in that line, not only /usr/bin/perl. If you are using Perl under Windows, you may want to put paths like: #!C:/perl/bin/perl #!C:/perl/bin/perl.exe If a Perl program uses this line under Unix/Linux and if the program is executable, it can be ran by just using: ./program_name without needing to use perl program_name Under Windows it doesn't help that line at all if you just need to run the programs from a command line. But it can help you if you need to run Perl programs as CGI scripts with Apache. I have Apache installed on E: drive and Perl on the same drive in the folder e:\usr and in this case I can use #!/usr/bin/perl as the first line in CGI scripts (although I haven't used CGI scripts for years:) --Octavian - Original Message - From: Sunita Rani Pradhan sunita.prad...@altair.com To: beginners@perl.org Sent: Tuesday, January 04, 2011 7:33 AM Subject: 1st line of perl script Hi All 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 . Why is it so ? Could anybody explain it clearly? Thanks Sunita -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: 1st line of perl script
I think this is very good info .. I have tried on Windows and Unix as well . - I found like , this line does not matter on windows . Windows need .pl extension but Unix/Linux does not . - Unix required this interpreter line when we are executing as , e.g ./test.pl or ./test. If the line is not given then inside script running on Unix , then need to execute it using perl interpreter externally . Thank you All . -Sunita -Original Message- From: alanhag...@gmail.com [mailto:alanhag...@gmail.com] On Behalf Of Alan Haggai Alavi Sent: Tuesday, January 04, 2011 11:16 AM To: Sunita Rani Pradhan Cc: beginners@perl.org Subject: Re: 1st line of perl script Hi Sunita, 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 . It is a shebang line which is only useful in Unix-like operating systems. In such systems, the shebang line should start in the first column of the first line. When such a script with its executable bit set is run by itself, the operating systems checks for the shebang line to see which interpreter should be used for executing the script. However, in Windows (and other non-Unix-like operating systems), the shebang is usually considered a comment and skipped. Instead of the shebang line, such systems depend on file extension associations or explicit invocation of the script using the interpreter. For more details, see: http://en.wikipedia.org/wiki/Shebang_(Unix) Regards, Alan Haggai Alavi. -- The difference makes the difference -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 1st line of perl script
On Tue, 04 Jan 2011 01:09:56 -0500, George Worroll wrote: On Windows, that line is just a comment. Neither the operating system nor the interpreter does anything with it. Not quite. Any options on the line (e.g., -T) will be activated. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ http://www.informit.com/store/product.aspx?isbn=0137001274 http://www.oreillyschool.com/courses/perl3/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/