$s = 241; $v = 73; @found = grep { -d $_ && m/$s\.$v_\w+/ } glob "/some/dir/*"; # DO STUFF WITH @found matches