sub delete { # accept a reference to an array (containing path values # to files to be removed) my $files_aref = shift; foreach (@$files) { # ... rest of your code ... } } # ... do something similar with the rest of our subs ...