nickcave25 has asked for the wisdom of the Perl Monks concerning the following question:


Back in the '80s, Frank Zappa came out with an album entitled Ship Arriving Too Late to Save a Drowning Witch.

My first forays into messing around with Taint mode are causing a similar message: "Too late for -T option..."

I realize that Taint mode writ large is a complex topic. I have read the Taint Mode FAQ and part of Lincoln Stein's Security FAQ (link available within previous link) so I know I have my work cut out for me. Which is fine.

For now, it would be oh-so helpful if someone could tell me why my two small snippets of code (borrowed from PERLTOOT) are generating this error message: Too late for -T option at persontest.pl line 1.

There's more than one way to do it, but the right way usually involves invoking Taint mode, according to Larry Wall, so please help me on this first step of what will be, I am sure, a long but rewarding journey.

Here's the code:

#!/usr/bin/perl5 -Tw ###### persontest.pl ###### perltoot ###### Person class Test code (page 4) use Person; $him = Person->new(); $him->name("Jason"); $him->age(23); $him->peers( "Norbert", "Rhys", "Phineas" ); push @allRecs, $him; #save object in array for later use printf "%s is %d years old.\n", $him->name, $him->age; print "His peers are:", join (", ", $him->peers), "\n"; printf "Last rec's name is %s\n", $allRecs[-1]->name; ###### person.pm ###### perltoot Person class ###### page 5 package Person; use strict; # object constructor sub new { my $self = {}; $self->{NAME} = undef; $self->{AGE} = undef; $self->{PEERS} = []; bless $self; return $self; } # per-object data access methods # With args, set the value; without only retrieve value(s) sub name { my $self = shift; if (@_) { $self->{NAME} = shift; } return $self->{NAME}; } sub age { my $self = shift; if (@_) { $self->{AGE} = shift;} return $self->{AGE}; } sub peers { my $self = shift; if (@_) { @{ $self->{PEERS} } = @_ } return @{ $self->{PEERS} } } 1;

Replies are listed 'Best First'.
Re (tilly) 1: Too Late for Drowning Witch/Taint Mode
by tilly (Archbishop) on Nov 01, 2000 at 05:16 UTC
    If ever you get a message you don't understand like this, run, do not walk, to a command prompt and type:
    perldoc perldiag
    Then hit "/", and type in part of the error text, then "n" until you hit the right match if you are not brought directly to the error.

    In this case you will find out that you are probably calling the script with perl script.pl when you need to make it executable and call it with ./script.pl.

Re: Too Late for Drowning Witch/Taint Mode
by Fastolfe (Vicar) on Nov 01, 2000 at 05:19 UTC
    You're typing (or your OS is executing the equivalent of the following):
    perl script.pl
    where script.pl has #!/usr/bin/perl -T. This is ineffectual, since the flags have to be passed straight away to the Perl interpreter. Execute your script one of the following ways instead:
    chmod +x script.pl ./script.pl # or: perl -T script.pl
Re: Too Late for Drowning Witch/Taint Mode
by chromatic (Archbishop) on Nov 01, 2000 at 09:28 UTC
    What tilly and Fastolfe have said is correct. I have seen this also happen with certain web servers and file associations.

    For example, your web server may be configured to invoke files ending in .pl or .cgi with 'perl.exe'. If possible, you may be able to add the -T flag to the association, set a TaintMode directive in the server configuration file, or write a wrapper batch or shell file that calls the interpreter with the right flags and passes the script name on to it.

    (I also like the use diagnostics; pragma instead of perldiag, when I'm really confused by something.)

Re: Too Late for Drowning Witch/Taint Mode
by nickcave25 (Acolyte) on Nov 02, 2000 at 06:43 UTC
    tilly, fastolfe, chromatic:

    Your suggestions were very helpful. Thanks for taking the time to reply!