This is the case for the underutilized Text::Balanced , a very convenient core module for this kind of thing. It relies on the pos beginning of the delimited sequence, which is first defined / set, so I usually call it like this:
#!/usr/bin/env perl use strict; use warnings; use Text::Balanced 'extract_bracketed'; sub get_bracketed { my $str = shift;
A regular expression with the gc modifier tells the line where the endpoint of the match is located, and extract_bracketed uses this information to know where to start.
Joel berger
source share