SHARYA...h::Util(3pm)
π NAME π
SHARYANTO::Hash::Util β it's giving hash utilities, bestie β¨ literally just a lil toolbox for your Perl hashes π
πΈ VERSION πΈ
This doc is describing version 0.77 of SHARYANTO::Hash::Util, which comes from the Perl distribution SHARYANTO-Utils, and it was released on 2015-09-04. Yeah she's an elder but she still slays π
π¦ SYNOPSIS π¦
okay so picture this, you just need to rename one key:
use SHARYANTO::Hash::Util qw(rename_key);
my %h = (a=>1, b=>2);
rename_key(\%h, "a", "alpha"); # %h = (alpha=>1, b=>2)
boom. done. iconic. π
β¨ FUNCTIONS β¨
π rename_key(\%hash, $old_key, $new_key)
Renames a key, no cap. Underneath it's basically $hash{$new_key} = delete $hash{$old_key} but with a couple extra lil checks sprinkled on top π§ It's a shortcut for exactly this:
die unless exists $hash{$old_key};
die if exists $hash{$new_key};
$hash{$new_key} = delete $hash{$old_key};
so like, it'll die if the old key isn't there, and it'll also die if the new key is already taken β because we are NOT about that overwrite life π
π replace_hash_content($hashref, @pairs) => $hashref
Replaces the content in $hashref with @list. Returns $hashref. And the important part: it does NOT make a new hashref object β so it's different from doing $hashref = {new=>"content"} π
bestie. listen. Do not use this function. In Perl you can literally just do %$hashref = @pairs. I put the function here as a reminder. That's it. That's the whole thing. π
π SEE ALSO π
SHARYANTO β go look at her, she's the mom of this whole situation π«Ά
π HOMEPAGE π
Wanna visit the project's homepage? It's right here, come thru:
<https://metacpan.org/release/SHARYANTO-Utils>
π SOURCE π
The source repository lives at:
<https://github.com/perlancar/perl-SHARYANTO-Utils>
go peek, go star it, go be nosy π
π BUGS π
Found a bug? Got a feature request? Please report it on the bugtracker website:
<https://rt.cpan.org/Public/Dist/Display.html?Name=SHARYANTO-Utils>
And when you submit a bug or a request, please include a test-file β or a patch to an existing test-file β that illustrates the bug or the desired feature. fr fr, that's the whole ask π
π AUTHOR π
perlancar <perlancar@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so like, go wild but respectfully β¨
and that's a wrap on SHARYA...h::Util(3pm) β this page came to you via perl v5.34.0, dated 2022-06-17. ty for coming to my ted talk, mwah ππ¦πΈ
π¦ where this page comes from
- debian bookworm: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms