Import upstream version 1.050+git20200206.1.42fefa4
Debian Janitor
1 year, 3 months ago
0 | 0 | ==== version history of Hash::Case |
1 | 1 | |
2 | 2 | All changes made by Mark Overmeer, unless explicitly stated otherwise. |
3 | ||
4 | version 1.06: | |
3 | 5 | |
4 | 6 | version 1.05: Thu 6 Feb 16:41:09 CET 2020 |
5 | 7 |
0 | 0 | ChangeLog |
1 | 1 | MANIFEST |
2 | 2 | Makefile.PL |
3 | README | |
4 | 3 | README.md |
5 | 4 | lib/Hash/Case.pm |
6 | lib/Hash/Case.pod | |
7 | 5 | lib/Hash/Case/Lower.pm |
8 | lib/Hash/Case/Lower.pod | |
9 | 6 | lib/Hash/Case/Preserve.pm |
10 | lib/Hash/Case/Preserve.pod | |
11 | 7 | lib/Hash/Case/Upper.pm |
12 | lib/Hash/Case/Upper.pod | |
13 | 8 | t/10lower.t |
14 | 9 | t/20upper.t |
15 | 10 | t/30pres1.t |
3 | 3 | "Mark Overmeer <markov@cpan.org>" |
4 | 4 | ], |
5 | 5 | "dynamic_config" : 1, |
6 | "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", | |
6 | "generated_by" : "ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010", | |
7 | 7 | "license" : [ |
8 | 8 | "perl_5" |
9 | 9 | ], |
47 | 47 | "web" : "https://github.com/markov2/perl5-Hash-Case" |
48 | 48 | } |
49 | 49 | }, |
50 | "version" : "1.05", | |
51 | "x_serialization_backend" : "JSON::PP version 2.94" | |
50 | "version" : "1.06", | |
51 | "x_serialization_backend" : "JSON::PP version 4.07" | |
52 | 52 | } |
6 | 6 | configure_requires: |
7 | 7 | ExtUtils::MakeMaker: '0' |
8 | 8 | dynamic_config: 1 |
9 | generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' | |
9 | generated_by: 'ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010' | |
10 | 10 | license: perl |
11 | 11 | meta-spec: |
12 | 12 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
22 | 22 | homepage: http://perl.overmeer.net/CPAN/ |
23 | 23 | license: http://dev.perl.org/licenses/ |
24 | 24 | repository: https://github.com/markov2/perl5-Hash-Case.git |
25 | version: '1.05' | |
26 | x_serialization_backend: 'CPAN::Meta::YAML version 0.011' | |
25 | version: '1.06' | |
26 | x_serialization_backend: 'CPAN::Meta::YAML version 0.018' |
3 | 3 | |
4 | 4 | WriteMakefile |
5 | 5 | ( NAME => 'Hash::Case' |
6 | , VERSION => '1.05' | |
6 | , VERSION => '1.06' | |
7 | 7 | , PREREQ_PM => |
8 | 8 | { Test::More => 0.47 |
9 | 9 | } |
0 | === README for Hash-Case version 1.04 | |
1 | = Generated on Thu Feb 6 16:22:41 2020 by OODoc 2.02 | |
2 | ||
3 | There are various ways to install this module: | |
4 | ||
5 | (1) if you have a command-line, you can do: | |
6 | perl -MCPAN -e 'install <any package from this distribution>' | |
7 | ||
8 | (2) if you use Windows, have a look at http://ppm.activestate.com/ | |
9 | ||
10 | (3) if you have downloaded this module manually (as root/administrator) | |
11 | gzip -d Hash-Case-1.04.tar.gz | |
12 | tar -xf Hash-Case-1.04.tar | |
13 | cd Hash-Case-1.04 | |
14 | perl Makefile.PL | |
15 | make # optional | |
16 | make test # optional | |
17 | make install | |
18 | ||
19 | For usage, see the included manual-pages or | |
20 | http://search.cpan.org/dist/Hash-Case-1.04/ | |
21 | ||
22 | Please report problems to | |
23 | http://rt.cpan.org/Dist/Display.html?Queue=Hash-Case | |
24 |
0 | # Hash::Case | |
1 | ||
2 | * My extended documentation: <http://perl.overmeer.net/CPAN/> | |
3 | * Development via GitHub: <https://github.com/markov2/perl5-Hash-Case> | |
4 | * Download from CPAN: <ftp://ftp.cpan.org/pub/CPAN/authors/id/M/MA/MARKOV/> | |
5 | * Indexed from CPAN: <https://metacpan.org/release/Hash-Case> | |
6 | ||
7 | Ties hashes to play tricks with keys. | |
8 | ||
9 | ## Development → Release | |
10 | ||
11 | Important to know, is that I use an extension on POD to write the manuals. | |
12 | The "raw" unprocessed version is visible on GitHub. It will run without | |
13 | problems, but does not contain manual-pages. | |
14 | ||
15 | Releases to CPAN are different: "raw" documentation gets removed from | |
16 | the code and translated into real POD and clean HTML. This reformatting | |
17 | is implemented with the OODoc distribution (A name I chose before OpenOffice | |
18 | existed, sorry for the confusion) | |
19 | ||
20 | Clone from github for the "raw" version. For instance, when you want | |
21 | to contribute a new feature. | |
22 | ||
23 | On github, you can find the processed version for each release. But the | |
24 | better source is CPAN; to get it installed simply run: | |
25 | ||
26 | ```sh | |
27 | cpan -i Hash::Case | |
28 | ``` | |
29 | ||
30 | ## Contributing | |
31 | ||
32 | When you want to contribute to this module, you do not need to provide | |
33 | a perfect patch... actually: it is nearly impossible to create a patch | |
34 | which I will merge without modification. Usually, I need to adapt the | |
35 | style of code and documentation to my own strict rules. | |
36 | ||
37 | When you submit an extension, please contribute a set with | |
38 | ||
39 | 1. code | |
40 | ||
41 | 2. code documentation | |
42 | ||
43 | 3. regression tests in t/ | |
44 | ||
45 | **Please note:** | |
46 | When you contribute in any way, you agree to transfer the copyrights to | |
47 | Mark Overmeer (you will get the honors in the code and/or ChangeLog). | |
48 | You also automatically agree that your contribution is released under | |
49 | the same license as this project: licensed as perl itself. | |
50 | ||
51 | ## Copyright and License | |
52 | ||
53 | This project is free software; you can redistribute it and/or modify it | |
54 | under the same terms as Perl itself. | |
55 | See <http://dev.perl.org/licenses/> | |
56 |
0 | # Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. | |
1 | # For other contributors see ChangeLog. | |
2 | # See the manual pages for details on the licensing terms. | |
3 | # Pod stripped from pm file by OODoc 2.02. | |
4 | 0 | # This code is part of distribution Hash::Case. Meta-POD processed with |
5 | 1 | # OODoc into POD and HTML manual-pages. See README.md |
6 | 2 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
7 | 3 | |
8 | 4 | package Hash::Case::Lower; |
9 | use vars '$VERSION'; | |
10 | $VERSION = '1.05'; | |
11 | ||
12 | 5 | use base 'Hash::Case'; |
13 | 6 | |
14 | 7 | use strict; |
15 | 8 | use warnings; |
16 | 9 | use Carp qw(croak); |
17 | 10 | |
11 | =chapter NAME | |
12 | ||
13 | Hash::Case::Lower - hash with enforced lower cased keys | |
14 | ||
15 | =chapter SYNOPSIS | |
16 | ||
17 | use Hash::Case::Lower; | |
18 | tie my(%lchash), 'Hash::Case::Lower'; | |
19 | $lchash{StraNGeKeY} = 3; | |
20 | print keys %lchash; # strangekey | |
21 | ||
22 | =chapter DESCRIPTION | |
23 | ||
24 | Hash::Case::Lower extends M<Hash::Case>, which lets you play various | |
25 | trics with hash keys. In this implementation, the fake hash is case | |
26 | insensitive and the keys stored in lower-case. | |
27 | ||
28 | =chapter METHODS | |
29 | ||
30 | =section Constructors | |
31 | ||
32 | =tie tie HASH, 'Hash::Case::Lower', [VALUES,] OPTIONS | |
33 | ||
34 | Define HASH to have only lower cased keys. The hash is initialized with | |
35 | the VALUES, specified as ref-array (with key value pairs) or ref-hash. | |
36 | Currently, there are no OPTIONS defined. | |
37 | ||
38 | =cut | |
18 | 39 | |
19 | 40 | sub init($) |
20 | 41 | { my ($self, $args) = @_; |
0 | =encoding utf8 | |
1 | ||
2 | =head1 NAME | |
3 | ||
4 | Hash::Case::Lower - hash with enforced lower cased keys | |
5 | ||
6 | =head1 INHERITANCE | |
7 | ||
8 | Hash::Case::Lower | |
9 | is a Hash::Case | |
10 | is a Tie::StdHash | |
11 | ||
12 | =head1 SYNOPSIS | |
13 | ||
14 | use Hash::Case::Lower; | |
15 | tie my(%lchash), 'Hash::Case::Lower'; | |
16 | $lchash{StraNGeKeY} = 3; | |
17 | print keys %lchash; # strangekey | |
18 | ||
19 | =head1 DESCRIPTION | |
20 | ||
21 | Hash::Case::Lower extends L<Hash::Case|Hash::Case>, which lets you play various | |
22 | trics with hash keys. In this implementation, the fake hash is case | |
23 | insensitive and the keys stored in lower-case. | |
24 | ||
25 | Extends L<"DESCRIPTION" in Hash::Case|Hash::Case/"DESCRIPTION">. | |
26 | ||
27 | =head1 METHODS | |
28 | ||
29 | Extends L<"METHODS" in Hash::Case|Hash::Case/"METHODS">. | |
30 | ||
31 | =head2 Constructors | |
32 | ||
33 | Extends L<"Constructors" in Hash::Case|Hash::Case/"Constructors">. | |
34 | ||
35 | =over 4 | |
36 | ||
37 | =item $obj-E<gt>B<addHashData>(HASH) | |
38 | ||
39 | Inherited, see L<Hash::Case/"Constructors"> | |
40 | ||
41 | =item $obj-E<gt>B<addPairs>(PAIRS) | |
42 | ||
43 | Inherited, see L<Hash::Case/"Constructors"> | |
44 | ||
45 | =item $obj-E<gt>B<setHash>(HASH) | |
46 | ||
47 | Inherited, see L<Hash::Case/"Constructors"> | |
48 | ||
49 | =item B<tie>(HASH, 'Hash::Case::Lower', [VALUES,] OPTIONS) | |
50 | ||
51 | Define HASH to have only lower cased keys. The hash is initialized with | |
52 | the VALUES, specified as ref-array (with key value pairs) or ref-hash. | |
53 | Currently, there are no OPTIONS defined. | |
54 | ||
55 | =back | |
56 | ||
57 | =head1 SEE ALSO | |
58 | ||
59 | This module is part of Hash-Case distribution version 1.05, | |
60 | built on February 06, 2020. Website: F<http://perl.overmeer.net/CPAN/> | |
61 | ||
62 | =head1 LICENSE | |
63 | ||
64 | Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
65 | ||
66 | This program is free software; you can redistribute it and/or modify it | |
67 | under the same terms as Perl itself. | |
68 | See F<http://dev.perl.org/licenses/> | |
69 |
0 | # Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. | |
1 | # For other contributors see ChangeLog. | |
2 | # See the manual pages for details on the licensing terms. | |
3 | # Pod stripped from pm file by OODoc 2.02. | |
4 | 0 | # This code is part of distribution Hash::Case. Meta-POD processed with |
5 | 1 | # OODoc into POD and HTML manual-pages. See README.md |
6 | 2 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
7 | 3 | |
8 | 4 | package Hash::Case::Preserve; |
9 | use vars '$VERSION'; | |
10 | $VERSION = '1.05'; | |
11 | ||
12 | 5 | use base 'Hash::Case'; |
13 | 6 | |
14 | 7 | use strict; |
15 | 8 | use warnings; |
16 | 9 | use Carp 'croak'; |
17 | 10 | |
11 | =chapter NAME | |
12 | ||
13 | Hash::Case::Preserve - hash with enforced lower cased keys | |
14 | ||
15 | =chapter SYNOPSIS | |
16 | ||
17 | use Hash::Case::Preserve; | |
18 | tie my(%cphash), 'Hash::Case::Preserve'; | |
19 | $cphash{StraNGeKeY} = 3; | |
20 | print keys %cphash; # StraNGeKeY | |
21 | print $cphash{strangekey}; # 3 | |
22 | print $cphash{STRANGEKEY}; # 3 | |
23 | ||
24 | =chapter DESCRIPTION | |
25 | ||
26 | Hash::Case::Preserve extends M<Hash::Case>, which lets you play | |
27 | various trics with hash keys. This extension implements a fake | |
28 | hash which is case-insentive. The keys are administered in the | |
29 | casing as they were used: case-insensitive but case-preserving. | |
30 | ||
31 | =chapter METHODS | |
32 | ||
33 | =section Constructors | |
34 | ||
35 | =tie tie HASH, 'Hash::Case::Preserve', [VALUES,] OPTIONS | |
36 | ||
37 | Define HASH to be case insensitive, but case preserving. | |
38 | The hash is initialized with the VALUES, specified as ref-array (passing | |
39 | a list of key-value pairs) or ref-hash. | |
40 | ||
41 | OPTIONS is a list of key/value pairs, which specify how the hash | |
42 | must handle preservation. Current options: | |
43 | ||
44 | =option keep 'FIRST' | 'LAST' | |
45 | =default keep 'LAST' | |
46 | Which casing is the preferred casing? The FIRST appearance or the LAST. | |
47 | Only stores will affect the casing, deletes will undo the definition. | |
48 | Defaults to LAST, which is slightly faster. | |
49 | ||
50 | =cut | |
18 | 51 | |
19 | 52 | sub init($) |
20 | 53 | { my ($self, $args) = @_; |
0 | =encoding utf8 | |
1 | ||
2 | =head1 NAME | |
3 | ||
4 | Hash::Case::Preserve - hash with enforced lower cased keys | |
5 | ||
6 | =head1 INHERITANCE | |
7 | ||
8 | Hash::Case::Preserve | |
9 | is a Hash::Case | |
10 | is a Tie::StdHash | |
11 | ||
12 | =head1 SYNOPSIS | |
13 | ||
14 | use Hash::Case::Preserve; | |
15 | tie my(%cphash), 'Hash::Case::Preserve'; | |
16 | $cphash{StraNGeKeY} = 3; | |
17 | print keys %cphash; # StraNGeKeY | |
18 | print $cphash{strangekey}; # 3 | |
19 | print $cphash{STRANGEKEY}; # 3 | |
20 | ||
21 | =head1 DESCRIPTION | |
22 | ||
23 | Hash::Case::Preserve extends L<Hash::Case|Hash::Case>, which lets you play | |
24 | various trics with hash keys. This extension implements a fake | |
25 | hash which is case-insentive. The keys are administered in the | |
26 | casing as they were used: case-insensitive but case-preserving. | |
27 | ||
28 | Extends L<"DESCRIPTION" in Hash::Case|Hash::Case/"DESCRIPTION">. | |
29 | ||
30 | =head1 METHODS | |
31 | ||
32 | Extends L<"METHODS" in Hash::Case|Hash::Case/"METHODS">. | |
33 | ||
34 | =head2 Constructors | |
35 | ||
36 | Extends L<"Constructors" in Hash::Case|Hash::Case/"Constructors">. | |
37 | ||
38 | =over 4 | |
39 | ||
40 | =item $obj-E<gt>B<addHashData>(HASH) | |
41 | ||
42 | Inherited, see L<Hash::Case/"Constructors"> | |
43 | ||
44 | =item $obj-E<gt>B<addPairs>(PAIRS) | |
45 | ||
46 | Inherited, see L<Hash::Case/"Constructors"> | |
47 | ||
48 | =item $obj-E<gt>B<setHash>(HASH) | |
49 | ||
50 | Inherited, see L<Hash::Case/"Constructors"> | |
51 | ||
52 | =item B<tie>(HASH, 'Hash::Case::Preserve', [VALUES,] OPTIONS) | |
53 | ||
54 | Define HASH to be case insensitive, but case preserving. | |
55 | The hash is initialized with the VALUES, specified as ref-array (passing | |
56 | a list of key-value pairs) or ref-hash. | |
57 | ||
58 | OPTIONS is a list of key/value pairs, which specify how the hash | |
59 | must handle preservation. Current options: | |
60 | ||
61 | -Option--Default | |
62 | keep 'LAST' | |
63 | ||
64 | =over 2 | |
65 | ||
66 | =item keep => 'FIRST' | 'LAST' | |
67 | ||
68 | Which casing is the preferred casing? The FIRST appearance or the LAST. | |
69 | Only stores will affect the casing, deletes will undo the definition. | |
70 | Defaults to LAST, which is slightly faster. | |
71 | ||
72 | =back | |
73 | ||
74 | =back | |
75 | ||
76 | =head1 SEE ALSO | |
77 | ||
78 | This module is part of Hash-Case distribution version 1.05, | |
79 | built on February 06, 2020. Website: F<http://perl.overmeer.net/CPAN/> | |
80 | ||
81 | =head1 LICENSE | |
82 | ||
83 | Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
84 | ||
85 | This program is free software; you can redistribute it and/or modify it | |
86 | under the same terms as Perl itself. | |
87 | See F<http://dev.perl.org/licenses/> | |
88 |
0 | # Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. | |
1 | # For other contributors see ChangeLog. | |
2 | # See the manual pages for details on the licensing terms. | |
3 | # Pod stripped from pm file by OODoc 2.02. | |
4 | 0 | # This code is part of distribution Hash::Case. Meta-POD processed with |
5 | 1 | # OODoc into POD and HTML manual-pages. See README.md |
6 | 2 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
7 | 3 | |
8 | 4 | package Hash::Case::Upper; |
9 | use vars '$VERSION'; | |
10 | $VERSION = '1.05'; | |
11 | ||
12 | 5 | use base 'Hash::Case'; |
13 | 6 | |
14 | 7 | use strict; |
15 | 8 | use warnings; |
16 | 9 | use Carp qw(croak); |
17 | 10 | |
11 | =chapter NAME | |
12 | ||
13 | Hash::Case::Upper - native hash with enforced lower cased keys | |
14 | ||
15 | =chapter SYNOPSIS | |
16 | ||
17 | use Hash::Case::Upper; | |
18 | tie my(%uchash), 'Hash::Case::Upper'; | |
19 | $uchash{StraNGeKeY} = 3; | |
20 | print keys %uchash; # STRANGEKEY | |
21 | ||
22 | =chapter DESCRIPTION | |
23 | ||
24 | Hash::Case::Upper extends M<Hash::Case>, which lets you play various | |
25 | trics with hash keys. In this implementation, the fake hash is case | |
26 | insensitive and the keys stored in upper-case. | |
27 | ||
28 | =chapter METHODS | |
29 | ||
30 | =section Constructors | |
31 | ||
32 | =tie tie HASH, 'Hash::Case::Upper', [VALUES,] OPTIONS | |
33 | ||
34 | Define HASH to have only upper cased keys. The hash is | |
35 | initialized with the VALUES, specified as ref-array or | |
36 | ref-hash. Currently, there are no OPTIONS defined. | |
37 | ||
38 | =cut | |
18 | 39 | |
19 | 40 | sub init($) |
20 | 41 | { my ($self, $args) = @_; |
0 | =encoding utf8 | |
1 | ||
2 | =head1 NAME | |
3 | ||
4 | Hash::Case::Upper - native hash with enforced lower cased keys | |
5 | ||
6 | =head1 INHERITANCE | |
7 | ||
8 | Hash::Case::Upper | |
9 | is a Hash::Case | |
10 | is a Tie::StdHash | |
11 | ||
12 | =head1 SYNOPSIS | |
13 | ||
14 | use Hash::Case::Upper; | |
15 | tie my(%uchash), 'Hash::Case::Upper'; | |
16 | $uchash{StraNGeKeY} = 3; | |
17 | print keys %uchash; # STRANGEKEY | |
18 | ||
19 | =head1 DESCRIPTION | |
20 | ||
21 | Hash::Case::Upper extends L<Hash::Case|Hash::Case>, which lets you play various | |
22 | trics with hash keys. In this implementation, the fake hash is case | |
23 | insensitive and the keys stored in upper-case. | |
24 | ||
25 | Extends L<"DESCRIPTION" in Hash::Case|Hash::Case/"DESCRIPTION">. | |
26 | ||
27 | =head1 METHODS | |
28 | ||
29 | Extends L<"METHODS" in Hash::Case|Hash::Case/"METHODS">. | |
30 | ||
31 | =head2 Constructors | |
32 | ||
33 | Extends L<"Constructors" in Hash::Case|Hash::Case/"Constructors">. | |
34 | ||
35 | =over 4 | |
36 | ||
37 | =item $obj-E<gt>B<addHashData>(HASH) | |
38 | ||
39 | Inherited, see L<Hash::Case/"Constructors"> | |
40 | ||
41 | =item $obj-E<gt>B<addPairs>(PAIRS) | |
42 | ||
43 | Inherited, see L<Hash::Case/"Constructors"> | |
44 | ||
45 | =item $obj-E<gt>B<setHash>(HASH) | |
46 | ||
47 | Inherited, see L<Hash::Case/"Constructors"> | |
48 | ||
49 | =item B<tie>(HASH, 'Hash::Case::Upper', [VALUES,] OPTIONS) | |
50 | ||
51 | Define HASH to have only upper cased keys. The hash is | |
52 | initialized with the VALUES, specified as ref-array or | |
53 | ref-hash. Currently, there are no OPTIONS defined. | |
54 | ||
55 | =back | |
56 | ||
57 | =head1 SEE ALSO | |
58 | ||
59 | This module is part of Hash-Case distribution version 1.05, | |
60 | built on February 06, 2020. Website: F<http://perl.overmeer.net/CPAN/> | |
61 | ||
62 | =head1 LICENSE | |
63 | ||
64 | Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
65 | ||
66 | This program is free software; you can redistribute it and/or modify it | |
67 | under the same terms as Perl itself. | |
68 | See F<http://dev.perl.org/licenses/> | |
69 |
0 | # Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. | |
1 | # For other contributors see ChangeLog. | |
2 | # See the manual pages for details on the licensing terms. | |
3 | # Pod stripped from pm file by OODoc 2.02. | |
4 | 0 | # This code is part of distribution Hash::Case. Meta-POD processed with |
5 | 1 | # OODoc into POD and HTML manual-pages. See README.md |
6 | 2 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
7 | 3 | |
8 | 4 | package Hash::Case; |
9 | use vars '$VERSION'; | |
10 | $VERSION = '1.05'; | |
11 | ||
12 | 5 | |
13 | 6 | use warnings; |
14 | 7 | use strict; |
17 | 10 | use base 'Tie::StdHash'; |
18 | 11 | use Carp qw(croak); |
19 | 12 | |
13 | =chapter NAME | |
14 | ||
15 | Hash::Case - base class for hashes with key-casing requirements | |
16 | ||
17 | =chapter SYNOPSIS | |
18 | ||
19 | use Hash::Case::Lower; | |
20 | tie my(%lchash), 'Hash::Case::Lower'; | |
21 | $lchash{StraNGeKeY} = 3; | |
22 | print keys %lchash; # strangekey | |
23 | ||
24 | =chapter DESCRIPTION | |
25 | ||
26 | Hash::Case is the base class for various classes which tie special | |
27 | treatment for the casing of keys. Be aware of the differences in | |
28 | implementation: C<Lower> and C<Upper> are tied native hashes: | |
29 | these hashes have no need for hidden fields or other assisting | |
30 | data structured. A case C<Preserve> hash will actually create | |
31 | three hashes. | |
32 | ||
33 | The following strategies are implemented: | |
34 | ||
35 | =over 4 | |
36 | ||
37 | =item * Hash::Case::Lower (native hash) | |
38 | ||
39 | Keys are always considered lower case. The internals of this | |
40 | module translate any incoming key to lower case before it is used. | |
41 | ||
42 | =item * Hash::Case::Upper (native hash) | |
43 | ||
44 | Like the ::Lower, but then all keys are always translated into | |
45 | upper case. This module can be of use for some databases, which | |
46 | do translate everything to capitals as well. To avoid confusion, | |
47 | you may want to have you own internal Perl hash do this as well. | |
48 | ||
49 | =item * Hash::Case::Preserve | |
50 | ||
51 | The actual casing is ignored, but not forgotten. | |
52 | ||
53 | =back | |
54 | ||
55 | =chapter METHODS | |
56 | ||
57 | =section Constructors | |
58 | ||
59 | =tie tie HASH, TIE, [VALUES,] OPTIONS | |
60 | ||
61 | Tie the HASH with the TIE package which extends L<Hash::Case>. The OPTIONS | |
62 | differ per implementation: read the manual page for the package you actually | |
63 | use. The VALUES is a reference to an array containing key-value pairs, | |
64 | or a reference to a hash: they fill the initial hash. | |
65 | ||
66 | =examples | |
67 | ||
68 | my %x; | |
69 | tie %x, 'Hash::Case::Lower'; | |
70 | $x{Upper} = 3; | |
71 | print keys %x; # 'upper' | |
72 | ||
73 | my @y = (ABC => 3, DeF => 4); | |
74 | tie %x, 'Hash::Case::Lower', \@y; | |
75 | print keys %x; # 'abc' 'def' | |
76 | ||
77 | my %z = (ABC => 3, DeF => 4); | |
78 | tie %x, 'Hash::Case::Lower', \%z; | |
79 | =cut | |
20 | 80 | |
21 | 81 | sub TIEHASH(@) |
22 | 82 | { my $class = shift; |
53 | 113 | $self; |
54 | 114 | } |
55 | 115 | |
116 | =method addPairs PAIRS | |
117 | Specify an even length list of alternating key and value to be stored in | |
118 | the hash. | |
119 | =cut | |
56 | 120 | |
57 | 121 | sub addPairs(@) |
58 | 122 | { my $self = shift; |
60 | 124 | $self; |
61 | 125 | } |
62 | 126 | |
127 | =method addHashData HASH | |
128 | Add the data of a hash (passed as reference) to the created tied hash. The | |
129 | existing values in the hash remain, the keys are adapted to the needs of the | |
130 | the casing. | |
131 | =cut | |
63 | 132 | |
64 | 133 | sub addHashData($) |
65 | 134 | { my ($self, $data) = @_; |
67 | 136 | $self; |
68 | 137 | } |
69 | 138 | |
139 | =method setHash HASH | |
140 | The functionality differs for native and wrapper hashes. For native | |
141 | hashes, this is the same as first clearing the hash, and then a call | |
142 | to M<addHashData()>. Wrapper hashes will use the hash you specify here | |
143 | to store the data, and re-create the mapping hash. | |
144 | =cut | |
70 | 145 | |
71 | 146 | sub setHash($) |
72 | 147 | { my ($self, $hash) = @_; # the native implementation is the default. |
0 | =encoding utf8 | |
1 | ||
2 | =head1 NAME | |
3 | ||
4 | Hash::Case - base class for hashes with key-casing requirements | |
5 | ||
6 | =head1 INHERITANCE | |
7 | ||
8 | Hash::Case | |
9 | is a Tie::StdHash | |
10 | ||
11 | Hash::Case is extended by | |
12 | Hash::Case::Lower | |
13 | Hash::Case::Preserve | |
14 | Hash::Case::Upper | |
15 | ||
16 | =head1 SYNOPSIS | |
17 | ||
18 | use Hash::Case::Lower; | |
19 | tie my(%lchash), 'Hash::Case::Lower'; | |
20 | $lchash{StraNGeKeY} = 3; | |
21 | print keys %lchash; # strangekey | |
22 | ||
23 | =head1 DESCRIPTION | |
24 | ||
25 | Hash::Case is the base class for various classes which tie special | |
26 | treatment for the casing of keys. Be aware of the differences in | |
27 | implementation: C<Lower> and C<Upper> are tied native hashes: | |
28 | these hashes have no need for hidden fields or other assisting | |
29 | data structured. A case C<Preserve> hash will actually create | |
30 | three hashes. | |
31 | ||
32 | The following strategies are implemented: | |
33 | ||
34 | =over 4 | |
35 | ||
36 | =item * Hash::Case::Lower (native hash) | |
37 | ||
38 | Keys are always considered lower case. The internals of this | |
39 | module translate any incoming key to lower case before it is used. | |
40 | ||
41 | =item * Hash::Case::Upper (native hash) | |
42 | ||
43 | Like the ::Lower, but then all keys are always translated into | |
44 | upper case. This module can be of use for some databases, which | |
45 | do translate everything to capitals as well. To avoid confusion, | |
46 | you may want to have you own internal Perl hash do this as well. | |
47 | ||
48 | =item * Hash::Case::Preserve | |
49 | ||
50 | The actual casing is ignored, but not forgotten. | |
51 | ||
52 | =back | |
53 | ||
54 | =head1 METHODS | |
55 | ||
56 | =head2 Constructors | |
57 | ||
58 | =over 4 | |
59 | ||
60 | =item $obj-E<gt>B<addHashData>(HASH) | |
61 | ||
62 | Add the data of a hash (passed as reference) to the created tied hash. The | |
63 | existing values in the hash remain, the keys are adapted to the needs of the | |
64 | the casing. | |
65 | ||
66 | =item $obj-E<gt>B<addPairs>(PAIRS) | |
67 | ||
68 | Specify an even length list of alternating key and value to be stored in | |
69 | the hash. | |
70 | ||
71 | =item $obj-E<gt>B<setHash>(HASH) | |
72 | ||
73 | The functionality differs for native and wrapper hashes. For native | |
74 | hashes, this is the same as first clearing the hash, and then a call | |
75 | to L<addHashData()|Hash::Case/"Constructors">. Wrapper hashes will use the hash you specify here | |
76 | to store the data, and re-create the mapping hash. | |
77 | ||
78 | =item B<tie>(HASH, TIE, [VALUES,] OPTIONS) | |
79 | ||
80 | Tie the HASH with the TIE package which extends L<Hash::Case>. The OPTIONS | |
81 | differ per implementation: read the manual page for the package you actually | |
82 | use. The VALUES is a reference to an array containing key-value pairs, | |
83 | or a reference to a hash: they fill the initial hash. | |
84 | ||
85 | example: | |
86 | ||
87 | my %x; | |
88 | tie %x, 'Hash::Case::Lower'; | |
89 | $x{Upper} = 3; | |
90 | print keys %x; # 'upper' | |
91 | ||
92 | my @y = (ABC => 3, DeF => 4); | |
93 | tie %x, 'Hash::Case::Lower', \@y; | |
94 | print keys %x; # 'abc' 'def' | |
95 | ||
96 | my %z = (ABC => 3, DeF => 4); | |
97 | tie %x, 'Hash::Case::Lower', \%z; | |
98 | ||
99 | =back | |
100 | ||
101 | =head1 SEE ALSO | |
102 | ||
103 | This module is part of Hash-Case distribution version 1.05, | |
104 | built on February 06, 2020. Website: F<http://perl.overmeer.net/CPAN/> | |
105 | ||
106 | =head1 LICENSE | |
107 | ||
108 | Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. | |
109 | ||
110 | This program is free software; you can redistribute it and/or modify it | |
111 | under the same terms as Perl itself. | |
112 | See F<http://dev.perl.org/licenses/> | |
113 |