G
G Klinedinst
Hi all,
I am writing a CGI program which will be receiving 5 variables via
the POST method and using them to query a DB. Everything is working
fine but I would like to limit the characters people can enter. My
problem is that perl's built in types aren't sufficient for me, and I
can't really figure out the proper way to do it.
I want to allow ONLY: A-Z a-z 1-9 _ / -
As you can see that is two extra characters than the Perl \w and !\W.
I can easily do something like this:
if( !( $name =~ /[\W]/ ))
but that excludes my hyphen and forward slash. I could also or it with
a search for the hyphen and forward slash, like this:
if( !( $name =~ /[\W]/ ) || ( $name =~ /[-\/]/ ) )
but that isn't what I want either because that will allow weird
characters as long as a hyphen or slash exists.
Can anyone point me in the right direction? Just maybe a suggestion of
a flag or something which would be useful and then I will figure it
out from there. Thanks a bunch.
-GPK
I am writing a CGI program which will be receiving 5 variables via
the POST method and using them to query a DB. Everything is working
fine but I would like to limit the characters people can enter. My
problem is that perl's built in types aren't sufficient for me, and I
can't really figure out the proper way to do it.
I want to allow ONLY: A-Z a-z 1-9 _ / -
As you can see that is two extra characters than the Perl \w and !\W.
I can easily do something like this:
if( !( $name =~ /[\W]/ ))
but that excludes my hyphen and forward slash. I could also or it with
a search for the hyphen and forward slash, like this:
if( !( $name =~ /[\W]/ ) || ( $name =~ /[-\/]/ ) )
but that isn't what I want either because that will allow weird
characters as long as a hyphen or slash exists.
Can anyone point me in the right direction? Just maybe a suggestion of
a flag or something which would be useful and then I will figure it
out from there. Thanks a bunch.
-GPK