Puppet is not a scripting language.
You can dress up this sort of thing in various ways, but in the end you need to either create a separate resource for each file you want to manage (directly), or use an Exec. For example, you could do this:
define patternfile($pattern, $replace) {
$filename = regsubst($pattern, $replace, $name)
file { $filename:
ensure => absent
}
}
patternfile { [1, 2, 3, 4, 5, 6, 7, 8, 9]:
pattern => '/var/directoryREPLACEME',
$replace => 'REPLACEME'
}
You could write something slightly more concise in Puppet's Ruby DSL, but it would still amount to declaring a separate resource for each file you want to ensure absent.
In practice, what you ask, in the general form about which you ask, is not often the best approach to the task. It may help to step back and look at the bigger picture.
John