in reply to Removing backtracking from a .*? regexp

Depending on the complexity of your $target and your data, you may find a gain by breaking your search up:

my $target = shift || 'word'; $target = qr/$target/; my $re = qr/a=<([^>]+)>/; while( <DATA> ) { next unless /$re/; my $s = $1; print "[$s]\n" if $s =~ /$target/; }