in reply to Bug with nested named capture buffers

Sounds like a bug to me too. Why don't you report it?

Update: Wait, don't. Perl bug #58082:

The problem has been noticed before, and is currently fixed in 'bleadperl', and will be available in 5.10.1.

  • Comment on Re: Bug with nested named capture buffers

Replies are listed 'Best First'.
Re^2: Bug with nested named capture buffers
by matthewshark (Initiate) on Aug 31, 2008 at 14:26 UTC
    Thanks for the help! The bug report contained a hint that led to a trivial workaround. Namely, that %- functions correctly, while %+ has problems. From %- you can implement %+ with something like this:
    my %plus = ();
    while (my ($k, $v) = each %-) {
        $plus{$k} = $v->[0] if scalar(@$v)>=1;
    }
    

      Great! Two quick tips:

      if scalar(@$v)>=1;
      can be written as
      if @$v;

      If you could please avoid <pre>...</pre> on PerlMonks. <c>...</c> is preferred. It also saves you from encoding "&", "<" and ">"