I am working on a project which at one point gets a list of files from an ftp server. At that point it either returns an arrayref of files OR if an optional regex reference
You could use something like:
sub capturing_groups{ my $re = shift; "" =~ /|$re/; return $#+; } say capturing_groups qr/fo(.)b(..)/;
Output:
2