Diego Riano wrote: > > Hello All > > I am having problem figuring out how to match two patterns. I have two > pattern and I would like to now if they are the same or if one of them > is a sub pattern of the other. Ej: > $pattern1=[agpr]oprs[cd]xxxxx9; > $pattern2=[agpr]oprs; > $pattern3=aors; > > $pattern2 is a "subpattern" of $pattern1, and $pattern3 is completely > different form 1 or 2. > > I was trying with If ($paternn1=~/$pattern2/){do somthing . .. } > put it just works if the left side is a string, with a pattern it does > not work
I am not sure I understod your question right but maybe something like this is what you want: my $pattern1 = '[agpr]oprs[cd]xxxxx9'; my $pattern2 = '[agpr]oprs'; if ($pattern1 =~ /\Q$pattern2/){ print 'hello'; } the "\Q" is used to escape meta characters. /Stefan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]