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.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.