in reply to Filtering files with lists of substitution patterns
Probably the simplest, if not the only, way would be to store subrefs in your array:
my @all_patterns = ( sub{ $_[0] =~ s/#.*// }, sub{ $_[0] =~ s/^\s+// }, sub{ $_[0] =~ s/\s+$// }, sub{ $_[0] =~ s/^Total// }, sub{ $_[0] =~ s/^,// }, );
Then your apply_patterns() becomes:
sub apply_patterns { $_->( $_[0] ) for @all_patterns[ @_[ 1 .. $#_ ] ]; }
You might be able to use the '_' prototype for the utility subs, but it gets messy.
|
|---|