use 5.010; use strict; use warnings; use MCE::Flow; die "Not enough arguments given\n" if @ARGV < 2; my $regex = shift; $regex = qr/$regex/; sub user_func { my ($mce, $slurp_ref, $chunk_id) = @_; if (my $match = ${ $slurp_ref } =~ $regex ? 1 : 0) { $mce->gather($match); $mce->abort; } } for my $filename (@ARGV) { my @match = mce_flow_f { use_slurpio => 1 }, \&user_func, $filename; say "File '$filename' does".( scalar @match ? "" : "n't" )." match"; } #### $ time ./file_map.pl patternabc big_file File 'big_file' doesn't match real 0m0.327s user 0m0.267s sys 0m0.060s $ time ./mce_slurp.pl patternabc big_file File 'big_file' doesn't match real 0m0.152s user 0m0.263s sys 0m0.118s