my $months = "1jan2feb3mar4apr5may6jun7jul8aug9sep10oct11nov12dec";

my $x = "Apr"; #the month we will search for

if ($months =~ s/.*(\d+)$x.*/$1/i) {
        print "recognized as month $months";
    }
else {  
    print "Unrecognized month name";
}
