Robin,
Robin said:
I am running active perl 8.2.3 Build 809 and I'm wondering why when I turn
on taint mode checking on the #!/usr/bin/perl line whenver I run the script
it gives me an error "Too late for -T option at bbs.pl line 1." and whenever
I run the script with perl -T bbs.pl it works fine
You have not said which platform you are running on.
What you hint at should behave correctly on most UNIX systems.
There are several well documented bugs in how DROSS and Windoze systems
invoke Perl programs . . .
....is there any
configuration file I can edit so perl will automatically understand it to be
run with a -T option? I want to run the script with a Perl IDE that I've
downloaded and it gives me this error unless I take out the -T option. Do I
have to take out the -T evertime I run the script with the IDE or is there
something I can do?
I assume Windoze.
From the ActivePerl user guide, look at
file://E:\Perl\html\faq\Windows\ActivePerl-Winfaq4.html#What_s_the_equivalent_of_the_she
(for E:, substitute the drive you have installed ActivePerl on):
<QUOTE>Unfortunately, Win32 platforms don't provide the shebang syntax, or
anything like it. You can try one of the two following methods to run a
script from the command line. If all else fails, you can always just call
the perl interpreter directly, as in perl myscript.pl.
.. . .
For Windows NT 4.0/2000, the coolest method is to use associated file types
(see How do I associate Perl scripts with perl?). If you've associated Perl
scripts with the .pl extension, you can just type the name of your file at
the command line and Windows NT/2000 will launch perl.exe for you.
</QUOTE>
I guess you could hard-wire "-T" into the Perl command line associated with
extension ".pl", but that would impose taint checking everywhere, which
would give you headaches.
If you change the PATHEXT environment variable to include .pl files, like
this:
SET PATHEXT=.pl;%PATHEXT%
you can just type the file name without an extension, and Windows NT/2000
will find the first .pl file in your path with that name. You may want to
set PATHEXT in the System control panel rather than on the command line.
Otherwise, you'll have to re-enter it each time the command prompt window
closes.
<QUOTE> Note that the file association method does not work for Windows 9x,
nor does it work with Windows NT/2000 if you have command extensions
disabled. You can, however, still start the Perl script from an Explorer
window if the extension is associated with perl.
Another option is to use the pl2bat utility distributed with ActivePerl to
convert your Perl script into a batch file. What this does is tag some Win32
batch language to the front of your script so that the system calls the perl
interpreter on the file. It's quite a clever piece of batch coding,
actually.
If you call the pl2bat utility on your Perl script helloworld.pl, like this:
C:\> pl2bat helloworld.pl
it will produce a batch file, helloworld.bat. You can then invoke the script
just like this:
C:\> helloworld
Hello, World!
You can pass command line parameters, as well. Your script can be in your
PATH, or in another directory, and the pl2bat code will usually find it and
execute it correctly. The big advantage of this over file associations is
that I/O redirection will work correctly.
pl2bat has a number of useful command line options to affect how the
wrapping is done, what command line switches to pass to perl, etc. Running
perldoc pl2bat at the command line will show a full description of these
options.
</QUOTE>
When I run this little script, called "trial_shebang.pl":
#!e:\perl\bin\perl.exe -wT
use strict;
print "Howdy do there\n"
I see what you saw:
D:\Clyde\perldev\Trial>trial_shebang.pl
Too late for "-T" option at D:\Clyde\perldev\Trial\trial_shebang.pl
line 1.
When I run:
D:\Clyde\perldev\Trial>pl2bat trial_shebang.pl
pl2bat creates a DROSS batch file "trial_shebang.bat"
When I run it, I see this:
D:\Clyde\perldev\Trial>trial_shebang
Howdy do there
Now, whether this is any help to you depends on how your IDE invokes your
Perl programs.
Which IDE was it?
..
Regards,
Clyde