Skip to content

Commit

Permalink
Simplify opt Q
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Nov 30, 2024
1 parent bb68114 commit a4f4e24
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/App/Ack.pm
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,13 @@ sub build_regex {

defined $str or App::Ack::die( 'No regular expression found.' );

if ( !$opt->{Q} ) {
# Check for lowercaseness before we do any modifications.
my $regex_is_lc = App::Ack::is_lowercase( $str );

if ( $opt->{Q} ) {
$str = quotemeta( $str );
}
else {
# Compile the regex to see if it dies or throws warnings.
local $SIG{__WARN__} = sub { App::Ack::die @_ }; # Anything that warns becomes a die.
my $scratch_regex = eval { qr/$str/ };
Expand All @@ -762,11 +768,6 @@ sub build_regex {
}
}

# Check for lowercaseness before we do any modifications.
my $regex_is_lc = App::Ack::is_lowercase( $str );

$str = quotemeta( $str ) if $opt->{Q};

my $scan_str = $str;

# Whole words only.
Expand Down

0 comments on commit a4f4e24

Please sign in to comment.