Hash::...eserve(3pm)

πŸ’– NAME πŸ’–

Hash::Case::Preserve β€” a hash with enforced lower cased keys, no cap 🫢

(also, hi bestie, this page is from the User Contributed Perl Documentation section, and the man page header/footer is a little shy so it shows up as Hash::...eserve(3pm) πŸ’…)


🌸 INHERITANCE 🌸

okay so the family tree is literally this:

Hash::Case::Preserve
  is a Hash::Case
  is a Tie::StdHash

she's got lineage, periodt πŸ‘‘


✨ SYNOPSIS ✨

use Hash::Case::Preserve;
tie my(%cphash), 'Hash::Case::Preserve';
$cphash{StraNGeKeY} = 3;
print keys %cphash;         # StraNGeKeY
print $cphash{strangekey};  # 3
print $cphash{STRANGEKEY};  # 3

look at her go 😭 storing the key exactly how you typed it but matching it no matter how you scream it back. iconic behaviour, honestly.


πŸ¦‹ DESCRIPTION πŸ¦‹

Hash::Case::Preserve extends Hash::Case, which lets you play various trics with hash keys. This extension implements a fake hash which is case-insentive. The keys are administered in the casing as they were used: case-insensitive but case-preserving. πŸ’–

(yes bestie, the original really does spell it "trics" and "case-insentive" β€” we keep the lore exactly as it is 🫢)

Extends "DESCRIPTION" in Hash::Case.


πŸŽ€ METHODS πŸŽ€

Extends "METHODS" in Hash::Case.

🧚 Constructors

Extends "Constructors" in Hash::Case.

  • tie %hash, 'Hash::Case::Preserve', [$values,] %options β€” define %hash to be case insensitive, but case preserving. The hash is initialized with the $values, specified as ARRAY (passing flat key-value pairs) or HASH. Improves base, see "Constructors" in Hash::Case.

Here's the options table, bestie, exactly as written:

-Option--Default
 keep    'LAST'
  • keep => 'FIRST'|'LAST' β€” which casing is the preferred casing? The FIRST appearance or the LAST. Only stores will affect the casing, deletes will undo the definition. Defaults to LAST, which is slightly faster. ⚑
ngl the keep option is the whole main character of this module, so pick your casing era wisely πŸ‘‘

πŸ™ˆ Hidden object access

Extends "Hidden object access" in Hash::Case.

  • $obj->addHashData(\%data) β€” Inherited, see "Hidden object access" in Hash::Case
  • $obj->addPairs(@pairs) β€” Inherited, see "Hidden object access" in Hash::Case
  • $obj->setHash(\%data) β€” Inherited, see "Hidden object access" in Hash::Case

🌈 SEE ALSO 🌈

This module is part of Hash-Case version 1.07, built on January 26, 2026. Website: http://perl.overmeer.net/CPAN/ πŸ¦‹


πŸ“œ LICENSE πŸ“œ

For contributors see file ChangeLog.

This software is copyright (c) 2002-2026 by Mark Overmeer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page, you ate that πŸ’…βœ¨

perl v5.40.1 Β· 2026-01-26 β€” and that's the footer date and Perl version, mwah, go forth and tie your hashes bestie πŸŽ€πŸ’–

πŸ“¦ where this page comes from