sub test { my $s = shift; my $l = length $s; if ($s =~ /[xyz]{$l}/) { print "$s matches\n"; return; } print "$s doesn't match\n"; }