> -----Original Message-----
> From: Leon [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 5:05 AM
> To: [EMAIL PROTECTED]
> Subject: how to construct regexes so that it do not match null
> 
> 
> Without using $key == $cid, 
> How to construct a pattern so that $key match $cid.
> I do not understand why in the undermentioned script, $key match $cid.
> All explanations would be very much appreciated.
> Thanks
> 
> use strict;
> my $cid = '';
> my $key = '1234';
> if ($key=~/\b$cid\b/) {
>     print 'true';           
> }else {print 'false'};

Hmm, why do you want to use a regex?

Anyway, you need:

   $key =~ /^$cid$/

But you need to be careful about what characters $cid
might contain, so you're better to say:

   $key =~ /^\Q$cid\E$/;

which is equivalent to the much more straightforward:

   $key eq $cid;


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

Reply via email to