Hash::Diff(3pm)

πŸ“¦
version 0.010 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Hash::Diff πŸ’–

okay bestie, so you know how you've got two hashes and you're like "what even changed between y'all"?? this is the module for that. Hash::Diff β€” it gives you back the difference between two hashes as a hash. like, a whole new hash. slay.


✨ SYNOPSIS ✨

    use Hash::Diff qw( diff );
    my %a = (
                'foo'    => 1,
            'bar'    => { a => 1, b => 1 },
        );
    my %b = (
                'foo'     => 2,
                'bar'    => { a => 1 },
        );

    my %c = %{ diff( \%a, \%b ) };

    # %c = %{ foo => 1, bar => { b => 1} }

see how %c just ✨appears✨ with the tea? that's the whole vibe. 🫢


🌸 DESCRIPTION 🌸

Hash::Diff returns the difference between two hashes as a hash. that's the whole thing. it's giving minimalist icon. πŸ’…

diff ( <hashref>, <hashref> )

diffs two hashes. returns a reference to the new hash. that's the main character right there. πŸ‘‘

left_diff ( <hashref>, <hashref> )

returns the values in the left hash that is not, or different from the right hash. so like, left side only, bestie β€” everything on the left that either isn't on the right at all or just isn't matching. πŸ’œ


πŸŽ€ CAVEATS πŸŽ€

okay listen, we have to be honest with each other here. πŸ™ˆ

  • this will not handle self-referencing/recursion within hashes well. like at all. it will get confused and we will not be helping it.
  • this will only handle HASH and SCALAR. that's the whole menu.

plans for a future version include incorporate deep recursion protection. and support for ARRAY. so like, someday. manifesting it. πŸ¦‹

fr fr though: don't come for this module with a self-referencing hash and expect magic. it said what it said.

πŸ’€ BUGS πŸ’€

sure! report here: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Hash::Diff

(the energy of "sure!" followed by a link is honestly iconic and i will not be changing it 😭)


πŸ‘‘ AUTHOR πŸ‘‘

Bjorn-Olav Strand <bo@startsiden.no>

🌈 CONTRIBUTOR 🌈

Charles McGarvey <ccm@cpan.org>


Copyright (c) 2010 ABC Startsiden AS. All rights reserved.

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.


and that's the page, bestie!! 🌸✨ this one's documented under perl v5.36.0, dated 2022-12-12 β€” go forth and diff your hashes, no cap. πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from