#!/usr/bin/perl
# https://perlmonks.org/?node_id=1222687
use strict;
use warnings;
my $nobacktick = qr/(?:\\.|[^\\`]++)*+/s;
while( <DATA> )
{
s/ $nobacktick \K ` $nobacktick ` / $& =~ s{<}{<}gr /gex;
print;
}
__DATA__
This is `my <string>` that I want to modify because the angle bracket
+is between backticks
This is `my <string>` that I want to modify because the angle brack
+et is between backticks
This is `a <string> I don't want to modify because it's not between ba
+ckticks
This is \`another <left_angle_bracket>`I don't want to modify because
+the first backtick is escaped but I do want to modify <the_last_left_
+angle_bracket>` between the backticks
`whole string with <string> enclosed in backticks`
`whole string with <string> not enclosed in backticks
`whole string with <string> not enclosed in backticks\`
Outputs:
This is `my <string>` that I want to modify because the angle brack
+et is between backticks
This is `my <string>` that I want to modify because the angle brack
+et is between backticks
This is `a <string> I don't want to modify because it's not between ba
+ckticks
This is \`another <left_angle_bracket>`I don't want to modify because
+the first backtick is escaped but I do want to modify <the_last_le
+ft_angle_bracket>` between the backticks
`whole string with <string> enclosed in backticks`
`whole string with <string> not enclosed in backticks
`whole string with <string> not enclosed in backticks\`