well, the second slash should follow immediately after the bracket (in
present case it adds another character to the reg-ex. If you can cut & paste
the code segment it would avoid typographical errors. When I use the
following it performs as expected w/o syntax error.

#!/usr/bin/perl

$serial = "4595WAD165";

if ($serial !~ m/[0-9]{3}[A-Z]{2}[0-9]{3}/ ) {
  print "alert\n";
  }

else {
  print "check\n";
  }

> -----Original Message-----
> From: Kamali Muthukrishnan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 26, 2002 10:17 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: pattern matching for serial number
>
>
> Sorry, while typing I missed the slash, it is there in my code as -
>   if ($serial !~ m/[0-9]{3}[A-Z]{2}[0-9]{3} /)
> Is there any thing wrong with this ?
> Kamali
> >>> fliptop <[EMAIL PROTECTED]> 04/26/02 08:54AM >>>
> Kamali Muthukrishnan wrote:
>
> > Hi guys :
> > I have serial numbers with a pattern : 3 numbers followed by 2
> capital letters followed by 3 numbers.
> > To validate this -
> >   if ($serial !~ m/[0-9]{3}[A-Z]{2}[0-9]{3} )
> >       {  # display error ;  }
> > I get a syntax error.
>
>
> i think you're missing a closing slash (/) in your regex.  the format is
>
> if $something =~ m/regex_here/
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to