Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^2: Filtering CGI Input

by davidj (Priest)
on Apr 24, 2005 at 07:10 UTC ( #450893=note: print w/ replies, xml ) Need Help??

in reply to Re: Filtering CGI Input
in thread Filtering CGI Input

No, it is not that simple as the following code demonstrates:

#!/usr/bin/perl use strict; my $num = "123abc"; print "valid\n" if $num > 0 && $num < 99999; exit;
This will print 'valid', even though it does not meet the OP's criteria.

Thus, if the value "123abc" is passed from a web form to a cgi script, the code you suggest will validate it. The reason for this is because when using numeric comparisons, Perl will treat any string that begins with a number as a number. This is clearly not what the OP wants.


Comment on Re^2: Filtering CGI Input
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://450893]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-12-02 06:21 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (35 votes), past polls