Leon wrote: > > 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'}; >
$cid is an empty string. So in reality there's written $key =~/\b\b/. \b stands for a word boundary and has a length of 0. In $key there are two word boundary, before the 1 and after the 4. So of course, where one word boundary is, there are two or three or million ones. (They all have a length of 0) Greetings, Andrea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]