Next Tricks of the Wizards 165

Caching

        {
          my %cmyk;
          sub cmyk {
            my $key = join ',' , @_;
            return $cmyk{$key} if exists $cmyk{$key};
            $cmyk{$key} = real_cmyk(@_);
          }
          sub real_cmyk {
            # as before ...
          }
        }


Next Copyright © 2003 M. J. Dominus