Fixed several ancient bugs related to pattern handling which have been discovered with the new Perl version