.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Tie::CPHash 3pm" .TH Tie::CPHash 3pm "2021-01-08" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Tie::CPHash \- Case preserving but case insensitive hash table .SH "VERSION" .IX Header "VERSION" This document describes version 2.000 of Tie::CPHash, released January 17, 2015. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Tie::CPHash 2; # allows initialization during tie \& tie %cphash, \*(AqTie::CPHash\*(Aq, key => \*(Aqvalue\*(Aq; \& \& $cphash{\*(AqHello World\*(Aq} = \*(AqHi there!\*(Aq; \& printf("The key \`%s\*(Aq was used to store \`%s\*(Aq.\en", \& tied(%cphash)\->key(\*(AqHELLO WORLD\*(Aq), \& $cphash{\*(AqHELLO world\*(Aq}); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Tie::CPHash module provides a hash table that is case preserving but case insensitive. This means that .PP .Vb 2 \& $cphash{KEY} $cphash{key} \& $cphash{Key} $cphash{keY} .Ve .PP all refer to the same entry. Also, the hash remembers which form of the key was last used to store the entry. The \f(CW\*(C`keys\*(C'\fR and \f(CW\*(C`each\*(C'\fR functions will return the key that was used to set the value. .PP An example should make this clear: .PP .Vb 6 \& tie %h, \*(AqTie::CPHash\*(Aq, Hello => \*(AqWorld\*(Aq; \& print $h{HELLO}; # Prints \*(AqWorld\*(Aq \& print keys(%h); # Prints \*(AqHello\*(Aq \& $h{HELLO} = \*(AqWORLD\*(Aq; \& print $h{hello}; # Prints \*(AqWORLD\*(Aq \& print keys(%h); # Prints \*(AqHELLO\*(Aq .Ve .PP Tie::CPHash version 2.000 introduced the ability to pass a list of \&\f(CW\*(C`key => value\*(C'\fR pairs to initialize the hash (along with the \&\f(CW\*(C`add\*(C'\fR method that powers it). The list must include a value for each key, or the constructor will croak. .PP The additional \f(CW\*(C`key\*(C'\fR method lets you fetch the case of a specific key: .PP .Vb 2 \& # When run after the previous example, this prints \*(AqHELLO\*(Aq: \& print tied(%h)\->key(\*(AqHello\*(Aq); .Ve .PP (The \f(CW\*(C`tied\*(C'\fR function returns the object that \f(CW%h\fR is tied to.) .PP If you need a case insensitive hash, but don't need to preserve case, just use \f(CW$hash{lc $key}\fR instead of \f(CW$hash{$key}\fR. This has a lot less overhead than Tie::CPHash. .PP \&\f(CW\*(C`use Tie::CPHash;\*(C'\fR does not export anything into your namespace. .SH "METHODS" .IX Header "METHODS" .SS "add" .IX Subsection "add" .Vb 2 \& tied(%h)\->add( key => value, ... ); \& tied(%h)\->add( \e@list_of_key_value_pairs ); .Ve .PP This method (introduced in version 2.000) adds keys and values to the hash. It's just like .PP .Vb 1 \& %h = @list_of_key_value_pairs; .Ve .PP except that it doesn't clear the hash first. It accepts either a list or an arrayref. It croaks if the list has an odd number of entries. It returns the tied hash object. .PP If the list contains duplicate keys, the last \f(CW\*(C`key => value\*(C'\fR pair in the list wins. (You can't pass a hashref to \f(CW\*(C`add\*(C'\fR because it would be ambiguous which key would win if two keys differed only in case.) .PP For people used to Tie::IxHash, \f(CW\*(C`add\*(C'\fR is aliased to both \f(CW\*(C`Push\*(C'\fR and \f(CW\*(C`Unshift\*(C'\fR. (Tie::CPHash does not preserve the order of keys.) .SS "key" .IX Subsection "key" .Vb 1 \& $set_using_key = tied(%h)\->key( $key ) .Ve .PP This method lets you fetch the case of a specific key. For example: .PP .Vb 2 \& $h{HELLO} = \*(AqWorld\*(Aq; \& print tied(%h)\->key(\*(AqHello\*(Aq); # prints HELLO .Ve .PP If the key does not exist in the hash, it returns \f(CW\*(C`undef\*(C'\fR. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .IP "Odd number of elements in CPHash add" 4 .IX Item "Odd number of elements in CPHash add" You passed a list with an odd number of elements to the \f(CW\*(C`add\*(C'\fR method (or to \f(CW\*(C`tie\*(C'\fR, which uses \f(CW\*(C`add\*(C'\fR). The list must contain a value for each key. .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" Tie::CPHash requires no configuration files or environment variables. .SH "INCOMPATIBILITIES" .IX Header "INCOMPATIBILITIES" None reported. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" No bugs have been reported. .SH "AUTHOR" .IX Header "AUTHOR" Christopher J. Madsen \f(CW\*(C`\*(C'\fR .PP Please report any bugs or feature requests to \f(CW\*(C`\*(C'\fR or through the web interface at . .PP You can follow or contribute to Tie-CPHash's development at . .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2015 by Christopher J. Madsen. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. .SH "DISCLAIMER OF WARRANTY" .IX Header "DISCLAIMER OF WARRANTY" \&\s-1BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE \*(L"AS IS\*(R" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.\s0 .PP \&\s-1IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE\s0 (\s-1INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE\s0), \s-1EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\s0