| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # | 
| 2 |  |  |  |  |  |  | #  This file is part of WebDyne. | 
| 3 |  |  |  |  |  |  | # | 
| 4 |  |  |  |  |  |  | #  This software is Copyright (c) 2017 by Andrew Speer . | 
| 5 |  |  |  |  |  |  | # | 
| 6 |  |  |  |  |  |  | #  This is free software, licensed under: | 
| 7 |  |  |  |  |  |  | # | 
| 8 |  |  |  |  |  |  | #    The GNU General Public License, Version 2, June 1991 | 
| 9 |  |  |  |  |  |  | # | 
| 10 |  |  |  |  |  |  | #  Full license text is available at: | 
| 11 |  |  |  |  |  |  | # | 
| 12 |  |  |  |  |  |  | # | 
| 13 |  |  |  |  |  |  | # | 
| 14 |  |  |  |  |  |  | package WebDyne::Err::Constant; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | #  Pragma | 
| 18 |  |  |  |  |  |  | # | 
| 19 | 2 |  |  | 2 |  | 11 | use strict qw(vars); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 58 |  | 
| 20 | 2 |  |  | 2 |  | 9 | use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK @EXPORT %Constant); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 108 |  | 
| 21 | 2 |  |  | 2 |  | 9 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 52 |  | 
| 22 | 2 |  |  | 2 |  | 8 | no warnings qw(uninitialized); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 70 |  | 
| 23 |  |  |  |  |  |  | local $^W=0; | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | #  Need the File::Spec module | 
| 27 |  |  |  |  |  |  | # | 
| 28 | 2 |  |  | 2 |  | 10 | use File::Spec; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 449 |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | #  Version information | 
| 32 |  |  |  |  |  |  | # | 
| 33 |  |  |  |  |  |  | $VERSION='1.250'; | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | #  Hash of constants | 
| 37 |  |  |  |  |  |  | # | 
| 38 |  |  |  |  |  |  | %Constant=( | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | #  Where we keep the error template | 
| 42 |  |  |  |  |  |  | # | 
| 43 |  |  |  |  |  |  | WEBDYNE_ERR_TEMPLATE => File::Spec->catfile(&class_dn(__PACKAGE__), 'error.psp'), | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | #  If set to 1, error messages will be sent as text/plain, not | 
| 47 |  |  |  |  |  |  | #  HTML. If ERROR_EXIT set, child will quit after an error | 
| 48 |  |  |  |  |  |  | # | 
| 49 |  |  |  |  |  |  | WEBDYNE_ERROR_TEXT => 0, | 
| 50 |  |  |  |  |  |  | WEBDYNE_ERROR_EXIT => 0, | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | ); | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | sub class_dn { | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | #  Get class dir | 
| 60 |  |  |  |  |  |  | # | 
| 61 | 2 |  |  | 2 | 0 | 4 | my $class=shift(); | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | #  Get package file name so we can look up in inc | 
| 65 |  |  |  |  |  |  | # | 
| 66 | 2 |  |  |  |  | 11 | (my $class_fn="${class}.pm")=~s/::/\//g; | 
| 67 | 2 |  | 50 |  |  | 10 | $class_fn=$INC{$class_fn} || | 
| 68 |  |  |  |  |  |  | die("unable to find location for $class in \%INC"); | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | #  Split | 
| 72 |  |  |  |  |  |  | # | 
| 73 | 2 |  |  |  |  | 70 | my $class_dn=(File::Spec->splitpath($class_fn))[1]; | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | } | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | #  Export constants to namespace, place in export tags | 
| 79 |  |  |  |  |  |  | # | 
| 80 |  |  |  |  |  |  | require Exporter; | 
| 81 |  |  |  |  |  |  | require WebDyne::Constant; | 
| 82 |  |  |  |  |  |  | @ISA=qw(Exporter WebDyne::Constant); | 
| 83 |  |  |  |  |  |  | +__PACKAGE__->local_constant_load(\%Constant); | 
| 84 |  |  |  |  |  |  | foreach (keys %Constant) {${$_}=$Constant{$_}} | 
| 85 |  |  |  |  |  |  | @EXPORT=map {'$' . $_} keys %Constant; | 
| 86 |  |  |  |  |  |  | @EXPORT_OK=@EXPORT; | 
| 87 |  |  |  |  |  |  | %EXPORT_TAGS=(all => [@EXPORT_OK]); | 
| 88 |  |  |  |  |  |  | $_=\%Constant; |