perl error checking routine 
Author Message
 perl error checking routine

$CGI::POST_MAX=1024 * 100;
&check_data;

sub check_data{
 if ($message =~ tr/a-zA-Z0-9?',$&.!\-\n\t //c) {
  die $errormessage = "Special characters are forbidden. You used one in the
message field.";
    &errorpage;}
 { die 'PLEASE NOTE: The MESSAGE field is restricted to Max = 800
characters...  Software error checking' if length $message > 800;

  }

The above, only permits certain characters which is fine.
However I would like a routine which also prevents pranksters from posting
very long continues strings.
I'm thinking maybe I could include <br> /n or even read(STDIN, $buffer,
$ENV{'CONTENT_LENGTH'});  ?
I'm not really sure where to start?
Any help appreciated.
Thanks.

--
millside
_____________



Tue, 02 Mar 2004 09:46:02 GMT  
 perl error checking routine
[unintelligible code deleted]

Quote:
>However I would like a routine which also prevents pranksters from posting
>very long continues strings.

You can't really prevent them from doing that. You can, however,
decline to accept it.

Quote:
>I'm not really sure where to start?

Depends on what you want to do. Below is a code snippet that'll spit
out the longest word and its length - you might want to use something
like that in your check code.

#!/usr/bin/perl -w
use strict;

my $message = 'lah di dah longlonglonglongword foo baz bar';

my $longest = (sort { $b->[0] <=> $a->[0] }
                        map { [length($_), $_ ] }
                                split( /\s+/, $message ))[0];

print "The longest word is '$longest->[1]' ($longest->[0] chars)\n";
__END__

HTH,
--

split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while



Tue, 02 Mar 2004 10:22:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Error : calling sub routine inside another sub routine

2. Need a routine to check for DATE

3. Module or script of data checking routines?

4. "group routines not implemented"-error while testing perl

5. Libbent: File.pm and Error.pm: OO File-I/O with error checking

6. Libbent: File.pm and Error.pm: OO File-I/O with error checking

7. Using perl to check for 404 errors

8. Automatic error checking in Perl 5?

9. Checking URL's for 404 Errors in Perl CGI

10. Using Perl to check for 404 errors

11. Error checking within perl script

12. Error checking a form via PERL

 

 
Powered by phpBB® Forum Software