Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
GetOptions( 'accept|a=s' => \my @accept, 'reject|r=s' => \my @reject, ) or die "Error with options\n"; my @filter = map eval "sub { \$_[0] =~ /$_/ }", @accept; push @filter, map eval "sub { \$_[0] !~ /$_/ }", @reject; # my @input = ([url, filename], ...); my @filtered = filter(@input); sub filter { return unless @filter; return map $_->[0], grep { my $f = $_; all { $_->($f->[1]) } @filter } @_; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Adding regex filters from command-line options
by ikegami (Patriarch) on Mar 17, 2025 at 19:12 UTC | |
by Anonymous Monk on Mar 17, 2025 at 20:20 UTC | |
by ikegami (Patriarch) on Mar 17, 2025 at 20:42 UTC | |
Re: Adding regex filters from command-line options
by Anonymous Monk on Mar 25, 2025 at 08:29 UTC | |
by hippo (Archbishop) on Mar 25, 2025 at 08:49 UTC |