I am trying to parse balanced text (actually, text written in LaTeX) using extract_bracketed from Text::Balanced. However, I did not get a correct match with the following code:
use Text::Balanced qw(extract_bracketed);
my $data = 'xxx \footnote{...} yyy';
(my $ext, my $rem, my $pre) = extract_bracketed($data, '{}', '\footnote');
print "\$ext = $ext\n";
print "\$rem = $rem\n";
print "\$pre = $pre\n";
This prints:
$ext =
$rem = xxx \footnote{...} yyy
$pre =
According to the documentation, this output means that a failure occurred, but I do not understand why.
What I actually want to extract is ..., i.e. the contents of the \footnote command.
Why is this happening and how can I fix it?