
package Addition;
use Carp;

sub AUTOLOAD {
  (my $name = $AUTOLOAD) =~ s/^.*:://;
  unless ($name =~ /^ComputeSumOf(\d+)(?:And\d+)+$/) {
    croak "Usage: $_[0]::ComputeSumOf###And###[And###]..\n";
  }
  my $sum = $1;
  while ($name =~ /And(\d+)/g) {
    $sum += $1;
  }

  *$AUTOLOAD = sub { $sum };

  goto  &$AUTOLOAD;
}

1;
