use strict; my $string = "zero one two three"; my $offset = 1; my $regex = '[^\\s]+\\s+' x $offset . '([^\\s]+)'; print $string =~ /$regex/; __END__ one