Rob Anderson wrote:
> Thanks but I don't see how this could work. I've tried using it, but to no
> avail

Hi Rob

I can't think what could be wrong if you've copied Janek's code. I've written
a simple subroutine with a persistent hash which simply counts the different
strings it's called with and dumps the hash on each call. This works fine, and
should help you fix your own code, but if not then post it here and we'll have
a look.

I hope this helps.

Rob D

    #!perl

    use strict;
    use warnings;

    test('apple');
    test('pear');
    test('apple');
    test('banana');
    test('grapefruit');
    test('apple');
    test('lemon');
    test('lemon');

    {
        my %cache;

        sub test {
            my $param = shift;
            $cache{$param}++;
            printf "%10s => %d\n", $_, $cache{$_} foreach keys %cache;
            print "    ------------\n";
        }
    }

    __END__

output

         apple => 1
        ------------
          pear => 1
         apple => 1
        ------------
          pear => 1
         apple => 2
        ------------
          pear => 1
         apple => 2
        banana => 1
        ------------
          pear => 1
    grapefruit => 1
         apple => 2
        banana => 1
        ------------
          pear => 1
    grapefruit => 1
         apple => 3
        banana => 1
        ------------
          pear => 1
    grapefruit => 1
         apple => 3
         lemon => 1
        banana => 1
        ------------
          pear => 1
    grapefruit => 1
         apple => 3
         lemon => 2
        banana => 1
        ------------




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to