Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Provide an option to set the re::engine to be used searches #214

wants to merge 2 commits into from

3 participants


The attached patch adds and documents this option:

=item B<--re-engine=name>

Use an alternative regular expression engine when searching. Pass the option,
e.g., "RE2" to load and use L<re::engine::RE2>.
Richard Simões added some commits
Richard Simões provide a re-engine option bdb87d0
Richard Simões document option ed945e6

Why would someone want to do this? I don't understand the benefit, and there's nothing in the docs that explains the benefit.


Perl's built-in regular expression engine is quite slow, for one. There are a couple re::engine modules that use NFA algorithms (RE2, Plan9), performing far better on large bodies of text.

And someone else pointed this out to me, but using re::engine::PCRE would let one use ack to emulate grep -P.

If either of those are persuasive, I can write a follow-up patch to better-document the option.


This has been moved to the ack2 queue: petdance/ack2#161

@hoelzro hoelzro closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2012
  1. provide a re-engine option

    Richard Simões authored
  2. document option

    Richard Simões authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 0 deletions.
  1. +7 −0
  2. +5 −0 ack
@@ -46,6 +46,7 @@ our $is_windows;
use File::Spec ();
use File::Glob ':glob';
use Getopt::Long ();
+use Module::Load ();
%ignore_dirs = (
@@ -241,6 +242,7 @@ sub get_command_line_options {
'passthru' => \$opt{passthru},
'print0' => \$opt{print0},
'Q|literal' => \$opt{Q},
+ 're-engine=s' => \$opt{re_engine},
'r|R|recurse' => sub { $opt{n} = 0 },
'show-types' => \$opt{show_types},
'smart-case!' => \$opt{smart_case},
@@ -790,6 +792,7 @@ File inclusion/exclusion:
-u, --unrestricted All files and directories searched
--[no]ignore-dir=name Add/Remove directory from the list of ignored dirs
-r, -R, --recurse Recurse into subdirectories (ack's default behavior)
+ --re-engine=name Use re::engine::* when searching
-n, --no-recurse No descending into subdirectories
-G REGEX Only search files that match REGEX
@@ -1052,6 +1055,10 @@ sub search_resource {
$display_filename = undef;
+ # Import re::engine::* if option is set:
+ $opt->{re_engine} and Module::Load::load(
+ "re::engine::" . delete($opt->{re_engine}), "import" );
# for --line processing
my $has_lines = 0;
my @lines;
5 ack
@@ -408,6 +408,11 @@ Quote all metacharacters in PATTERN, it is treated as a literal.
This applies only to the PATTERN, not to the regexes given for the B<-g>
and B<-G> options.
+=item B<--re-engine=name>
+Use an alternative regular expression engine when searching. Pass the option,
+e.g., "RE2" to load and use L<re::engine::RE2>.
=item B<-r>, B<-R>, B<--recurse>
Recurse into sub-directories. This is the default and just here for
Something went wrong with that request. Please try again.