#!/usr/bin/perl my $test = "4321234"; if ($test =~ m/(\d)((??{ $1 + 1}))/) { print "matched $1 $2 \n"; } __END__ matched 1 2