in reply to validation of posted data.

It's already been said here, but it's worth saying again:

Don't try to exclude all `illegal' or `invalid' characters. You'll never get them all. Instead, decide what you will accept, and make sure your input contains that, and nothing else.

I'd write your regexp something like this:

unless ( $display =~ /^[a-z0-9\-\.]+$/ ) { # Invalid input }

_______________
D a m n D i r t y A p e
Home Node | Email

Replies are listed 'Best First'.
Re: Re: validation of posted data.
by Cine (Friar) on Jul 31, 2002 at 22:15 UTC
    I've found
    if ($display =~ /[^\-a-z0-9\.]/) { #err }
    to be easiere to read most of the time.
    Also if you _read_ the code, Yours says: unless $display is all good chars make an error. Where this says: If there are any illegal chars make an error. I find the latter easiere to understand.

    T I M T O W T D I

      Kind of a tangent, here, but isn't "." acceptable by itself (i.e., unescaped) in a character class, since its function as a metacharacter there wouldn't make much sense?

      BCE
      --Your punctuation skills are insufficient!

        Yes I believe it is, but I find it easiere to see that a literal period is required when it is escaped instead of examining the context and determening it from there.

        T I M T O W T D I