erabus has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Is there a module (or technique) for calculating a checksum on an array or hash reference without first dumping the reference to a string? Thanks.

Replies are listed 'Best First'.
Re: Calculating a checksum on a reference
by Bro. Doug (Monk) on Mar 20, 2007 at 01:05 UTC
    Hi,

    Is dereferencing okay? You can checksum like:
    # you can find this documented in various places # I believe its known as a System V sum. my $sum = unpack( "%32C*", $string ) % 65535 ;
    So, if you had a reference, you could just dereference it.
    my $sum = unpack( "%32C*", $$str_ref ) % 65535 ;
    Peace,
    Bro. Doug :wq
      The OP asked about array or hash references, not references to strings. Seems to me he wants to checksum the array's or hash's content.