in reply to Filtering files with lists of substitution patterns

As long as the right part of the substitution if the same (nothing, in your case) you can easily use references to regexen with qr, and if you want a custom replacement, you would have to use the e switch for non constant strings.

So in your case that would be :

my @patterns = (qr/#.*/, qr{$^\s+}, qr{\s+$}, qr/^,/); sub apply_patterns { $_[0] =~ s/$_// for (@patterns[ @_[ 1 .. $#_ ] ]); }
I usually don't like user subs to modify their parameters unless they are methods though. And calling the patterns by what they do rather than their number would make more sense. So you could actually just write:
my %patterns = ( comment => qr/#.*/, leadingSpaces => qr{$^\s+}, trailingSpaces => qr{\s+$}, leadingComma => qr/^,/ ); while(my $line = <FILE1>) { $line =~ s/$_// for %patterns{qw/comment trailingSpaces/}; }