Skip to content

Commit

Permalink
Add a work-around function for older Perls
Browse files Browse the repository at this point in the history
  • Loading branch information
scottchiefbaker committed Nov 29, 2023
1 parent bd69285 commit 8825840
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pod/perlvar.pod
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,23 @@ information on this form and its uses.

This variable was added in 5.25.7

sub get_captures {
my $str = $&;
my @captures = ();

# Build array using the offsets from @- and @+
for (my $i = 1; $i < @-; $i++) {
my $start = $-[$i];
my $end = $+[$i];
my $len = $end - $start;

my $str = substr($str, $start, $len);
push(@captures, $str);
}

return @captures;
}

=item $MATCH

=item $&
Expand Down

0 comments on commit 8825840

Please sign in to comment.