- if (length $p > 1) {
- return 'my $r = ' . $opts->{ref} . '(' . $cur . '); '
- . join ' els',
- map( {
- "if (\$r eq '" . $reftypes{$_} ."') { "
- . _wrap($name, $proto, ($i + 1),
- $args . $_ . '{' . $cur . '}, ',
- $cr, $opts)
- . ' }'
- } split //, $p),
- 'e { ' . $opts->{wrong_ref} . ' }'
+ if (length $sigil > 1) {
+ my $code = "my \$r = $opts->{ref}($cur); ";
+ my @branches = map {
+ my $subcall = _wrap(
+ $name, $proto, ($i + 1), $args . "$_\{$cur}, ", $coderefs, $opts
+ );
+ "if (\$r eq '$reftypes{$_}') { $subcall }";
+ } split //, $sigil;
+ $code .= join ' els', @branches, "e { $opts->{wrong_ref} }";
+ return $code;