Re: improved error diagnostic for FromCGI->untaint_columns

[prev] [thread] [next] [Date index for 2004/11/01]

From: Dave Howorth
Subject: Re: improved error diagnostic for FromCGI->untaint_columns
Date: 14:39 on 01 Nov 2004
Edward J. Sabol wrote:
> I think you'll find that most of the modules on CPAN don't check method
> arguments like that. If they all did, the performance of everyone's
> applications would degrade significantly. Rather, I suggest you add "-w" to
> your perl command line or "use warnings;" in your programs. That will help
> you catch programming errors like this by informing you of an "Odd number of
> elements in hash assignment on line XXX."

I *always* use warnings but FromCGI->untaint_columns() does not produce 
a warning. Even with -W on the command line (that's CAPITAL-W). I don't 
understand why - there's a simple test program and output below. If you 
can tell me how to get a warning, I'd be more than happy to drop my request.

As to efficiency, I was assuming it would be wrapped in an if $debug, so 
there would be no impact on efficiency at runtime unless you asked for 
help. Guess I should have said that explicitly.

Cheers, Dave

==============================

#!/usr/bin/perl
use strict;
use warnings;

package Junk;

my %hash = (1 => 2, 3 => 4, => 5);

use Data::Dumper;
print Dumper(\%hash);
print "\n";

sub junk
{
  my ($a, %hash) = @_;
  print Dumper(\%hash);
  print "\n";
}

junk(1, 2, 3, 4, 5, 6);

use base 'Class::DBI';
use Class::DBI::FromCGI;
Junk->untaint_columns(1,2,3,4,5);

====================================

$ ./junk.pl -W
Odd number of elements in hash assignment at ./junk.pl line 7.
$VAR1 = {
           '1' => 2,
           '3' => 4,
           '5' => undef
         };

Odd number of elements in hash assignment at ./junk.pl line 15.
$VAR1 = {
           '2' => 3,
           '4' => 5,
           '6' => undef
         };

Re: improved error diagnostic for FromCGI->untaint_columns
Dave Howorth 14:39 on 01 Nov 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52