I am doing the pattern matching as below. But I am not getting the proper output. Please suggest the correct code to get the correct output.
code
#! /usr/bin/perl -w
my $subString = "1.3.6.1.2.1.26.2.1.1.1.";
my $wholeString = "1.3.6.1.2.1.26.2.1.1.12.1";
if ($wholeString =~ m/^$subString/)
{
print "matched string is : $&\n";
print "Wrong!!!!\n";
}
else
{
print "matched string is : $&\n";
print "Right!!!!!\n";
}
Actual Output: matched string is : 1.3.6.1.2.1.26.2.1.1.12 Wrong!!!!
Expected Output: matched string is : 1.3.6.1.2.1.26.2.1.1.1. Right!!!!!
What should I change in the code to get the expected output? Please