/usr/share/perl/5.14.2/Locale/Currency.pm is in perl-modules 5.14.2-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | package Locale::Currency;
# Copyright (C) 2001 Canon Research Centre Europe (CRE).
# Copyright (C) 2002-2009 Neil Bowers
# Copyright (c) 2010-2011 Sullivan Beck
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
use strict;
use warnings;
require 5.002;
require Exporter;
use Carp;
use Locale::Codes;
use Locale::Constants;
use Locale::Codes::Currency;
#=======================================================================
# Public Global Variables
#=======================================================================
our($VERSION,@ISA,@EXPORT,@EXPORT_OK);
$VERSION='3.16';
@ISA = qw(Exporter);
@EXPORT = qw(code2currency
currency2code
all_currency_codes
all_currency_names
currency_code2code
LOCALE_CURR_ALPHA
LOCALE_CURR_NUMERIC
);
sub _code {
my($code,$codeset) = @_;
$code = "" if (! $code);
$codeset = LOCALE_CURR_DEFAULT if (! defined($codeset) || $codeset eq "");
if ($codeset =~ /^\d+$/) {
if ($codeset == LOCALE_CURR_ALPHA) {
$codeset = "alpha";
} elsif ($codeset == LOCALE_CURR_NUMERIC) {
$codeset = "num";
} else {
return (1);
}
}
if ($codeset eq "alpha") {
$code = uc($code);
} elsif ($codeset eq "num") {
if (defined($code) && $code ne "") {
return (1) unless ($code =~ /^\d+$/);
$code = sprintf("%.3d", $code);
}
} else {
return (1);
}
return (0,$code,$codeset);
}
#=======================================================================
#
# code2currency ( CODE [,CODESET] )
#
#=======================================================================
sub code2currency {
my($err,$code,$codeset) = _code(@_);
return undef if ($err ||
! defined $code);
return Locale::Codes::_code2name("currency",$code,$codeset);
}
#=======================================================================
#
# currency2code ( CURRENCY [,CODESET] )
#
#=======================================================================
sub currency2code {
my($currency,$codeset) = @_;
my($err,$tmp);
($err,$tmp,$codeset) = _code("",$codeset);
return undef if ($err ||
! defined $currency);
return Locale::Codes::_name2code("currency",$currency,$codeset);
}
#=======================================================================
#
# currency_code2code ( CODE,CODESET_IN,CODESET_OUT )
#
#=======================================================================
sub currency_code2code {
(@_ == 3) or croak "currency_code2code() takes 3 arguments!";
my($code,$inset,$outset) = @_;
my($err,$tmp);
($err,$code,$inset) = _code($code,$inset);
return undef if ($err);
($err,$tmp,$outset) = _code("",$outset);
return undef if ($err);
return Locale::Codes::_code2code("currency",$code,$inset,$outset);
}
#=======================================================================
#
# all_currency_codes ( [CODESET] )
#
#=======================================================================
sub all_currency_codes {
my($codeset) = @_;
my($err,$tmp);
($err,$tmp,$codeset) = _code("",$codeset);
return undef if ($err);
return Locale::Codes::_all_codes("currency",$codeset);
}
#=======================================================================
#
# all_currency_names ( [CODESET] )
#
#=======================================================================
sub all_currency_names {
my($codeset) = @_;
my($err,$tmp);
($err,$tmp,$codeset) = _code("",$codeset);
return undef if ($err);
return Locale::Codes::_all_names("currency",$codeset);
}
#=======================================================================
#
# rename_currency ( CODE,NAME [,CODESET] )
#
#=======================================================================
sub rename_currency {
my($code,$new_name,@args) = @_;
my $nowarn = 0;
$nowarn = 1, pop(@args) if ($args[$#args] eq "nowarn");
my $codeset = shift(@args);
my $err;
($err,$code,$codeset) = _code($code,$codeset);
return Locale::Codes::_rename("currency",$code,$new_name,$codeset,$nowarn);
}
#=======================================================================
#
# add_currency ( CODE,NAME [,CODESET] )
#
#=======================================================================
sub add_currency {
my($code,$name,@args) = @_;
my $nowarn = 0;
$nowarn = 1, pop(@args) if ($args[$#args] eq "nowarn");
my $codeset = shift(@args);
my $err;
($err,$code,$codeset) = _code($code,$codeset);
return Locale::Codes::_add_code("currency",$code,$name,$codeset,$nowarn);
}
#=======================================================================
#
# delete_currency ( CODE [,CODESET] )
#
#=======================================================================
sub delete_currency {
my($code,@args) = @_;
my $nowarn = 0;
$nowarn = 1, pop(@args) if ($args[$#args] eq "nowarn");
my $codeset = shift(@args);
my $err;
($err,$code,$codeset) = _code($code,$codeset);
return Locale::Codes::_delete_code("currency",$code,$codeset,$nowarn);
}
#=======================================================================
#
# add_currency_alias ( NAME,NEW_NAME )
#
#=======================================================================
sub add_currency_alias {
my($name,$new_name,$nowarn) = @_;
$nowarn = (defined($nowarn) && $nowarn eq "nowarn" ? 1 : 0);
return Locale::Codes::_add_alias("currency",$name,$new_name,$nowarn);
}
#=======================================================================
#
# delete_currency_alias ( NAME )
#
#=======================================================================
sub delete_currency_alias {
my($name,$nowarn) = @_;
$nowarn = (defined($nowarn) && $nowarn eq "nowarn" ? 1 : 0);
return Locale::Codes::_delete_alias("currency",$name,$nowarn);
}
#=======================================================================
#
# rename_currency_code ( CODE,NEW_CODE [,CODESET] )
#
#=======================================================================
sub rename_currency_code {
my($code,$new_code,@args) = @_;
my $nowarn = 0;
$nowarn = 1, pop(@args) if ($args[$#args] eq "nowarn");
my $codeset = shift(@args);
my $err;
($err,$code,$codeset) = _code($code,$codeset);
($err,$new_code,$codeset) = _code($new_code,$codeset) if (! $err);
return Locale::Codes::_rename_code("currency",$code,$new_code,$codeset,$nowarn);
}
#=======================================================================
#
# add_currency_code_alias ( CODE,NEW_CODE [,CODESET] )
#
#=======================================================================
sub add_currency_code_alias {
my($code,$new_code,@args) = @_;
my $nowarn = 0;
$nowarn = 1, pop(@args) if ($args[$#args] eq "nowarn");
my $codeset = shift(@args);
my $err;
($err,$code,$codeset) = _code($code,$codeset);
($err,$new_code,$codeset) = _code($new_code,$codeset) if (! $err);
return Locale::Codes::_add_code_alias("currency",$code,$new_code,$codeset,$nowarn);
}
#=======================================================================
#
# delete_currency_code_alias ( CODE [,CODESET] )
#
#=======================================================================
sub delete_currency_code_alias {
my($code,@args) = @_;
my $nowarn = 0;
$nowarn = 1, pop(@args) if ($args[$#args] eq "nowarn");
my $codeset = shift(@args);
my $err;
($err,$code,$codeset) = _code($code,$codeset);
return Locale::Codes::_delete_code_alias("currency",$code,$codeset,$nowarn);
}
1;
# Local Variables:
# mode: cperl
# indent-tabs-mode: nil
# cperl-indent-level: 3
# cperl-continued-statement-offset: 2
# cperl-continued-brace-offset: 0
# cperl-brace-offset: 0
# cperl-brace-imaginary-offset: 0
# cperl-label-offset: -2
# End:
|