| 1 | package oEdtk::Util; | ||
| 2 | |||
| 3 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 3 | our $VERSION = 2.1126; | |
| 7 | 3 | our @ISA = qw(Exporter); | |
| 8 | 3 | our @EXPORT_OK = qw(_uc_hash_keys); | |
| 9 | |||
| 10 | # Convert all hash keys to uppercase, useful | ||
| 11 | # because PostgreSQL returns column names in lowercase. | ||
| 12 | # | ||
| 13 | # XXX This function is no longer used now that we set | ||
| 14 | # the 'FetchHashKeyName' option to 'NAME_uc' in DBAdmin.pm. | ||
| 15 | 1 | ▶ | sub _uc_hash_keys { |
|
Subroutine
_uc_hash_keys: called CC=2 SCAR=6.9
| |||
| 16 | 1 | my $hash = shift; | |
| 17 | |||
| 18 | 1 | $hash->{ uc $_ } = delete $hash->{$_} for keys %$hash; | |
| 19 | 1 | return $hash; | |
| 20 | } | ||
| 21 | |||
| 22 | 3 | 1; | |
| 23 | |||
| 24 | =head1 NAME | ||
| 25 | |||
| 26 | oEdtk::Util - small one-off utility helpers | ||
| 27 | |||
| 28 | =head1 SYNOPSIS | ||
| 29 | |||
| 30 | use oEdtk::Util qw(_uc_hash_keys); | ||
| 31 | |||
| 32 | my $h = { name => 'x', len => 3 }; | ||
| 33 | _uc_hash_keys($h); # { NAME => 'x', LEN => 3 } | ||
| 34 | |||
| 35 | =head1 DESCRIPTION | ||
| 36 | |||
| 37 | Holds small standalone helpers that do not belong to a larger module. The | ||
| 38 | current helper uppercases the keys of a column-name hash; it is kept for | ||
| 39 | compatibility. | ||
| 40 | |||
| 41 | =head1 FUNCTIONS | ||
| 42 | |||
| 43 | =head2 _uc_hash_keys | ||
| 44 | |||
| 45 | my $hash = _uc_hash_keys($hash); | ||
| 46 | |||
| 47 | Uppercase every key of the hash reference C<$hash> in place and return it. It | ||
| 48 | was used to normalise the lowercase column names returned by PostgreSQL; it is | ||
| 49 | no longer needed now that C<oEdtk::DBAdmin> sets the C<FetchHashKeyName> | ||
| 50 | option to C<NAME_uc>. | ||
| 51 | |||
| 52 | =head1 AUTHOR | ||
| 53 | |||
| 54 | The oEdtk team. | ||
| 55 | |||
| 56 | =cut | ||