| 1 | package Dev::Util::Const; | ||
| 2 | |||
| 3 | 2 | ▶ | use Dev::Util::Syntax; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use Exporter qw(import); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | our $VERSION = version->declare("v2.19.42"); | |
| 7 | |||
| 8 | 2 | our %EXPORT_TAGS = ( | |
| 9 | named_constants => [ qw( | ||
| 10 | $EMPTY_STR | ||
| 11 | $SPACE | ||
| 12 | $SINGLE_QUOTE | ||
| 13 | $DOUBLE_QUOTE | ||
| 14 | $COMMA | ||
| 15 | ) | ||
| 16 | ] | ||
| 17 | ); | ||
| 18 | |||
| 19 | # add all the other ":class" tags to the ":all" class, deleting duplicates | ||
| 20 | { | ||
| 21 | 2 | my %seen; | |
| 22 | 2 | push @{ $EXPORT_TAGS{ all } }, grep { !$seen{ $_ }++ } @{ $EXPORT_TAGS{ $_ } } | |
| 23 | 2 | foreach keys %EXPORT_TAGS; | |
| 24 | } | ||
| 25 | 2 | Exporter::export_tags('all'); | |
| 26 | 2 | Exporter::export_ok_tags('all'); | |
| 27 | |||
| 28 | 2 | ▶ | sub _define_named_constants { |
|
Subroutine
_define_named_constants: called CC=1 SCAR=0.0
| |||
| 29 | 2 | Readonly our $EMPTY_STR => q{}; | |
| 30 | 2 | Readonly our $SPACE => q{ }; | |
| 31 | 2 | Readonly our $SINGLE_QUOTE => q{'}; | |
| 32 | 2 | Readonly our $DOUBLE_QUOTE => q{"}; | |
| 33 | 2 | Readonly our $COMMA => q{,}; | |
| 34 | 2 | return; | |
| 35 | } | ||
| 36 | 2 | _define_named_constants(); | |
| 37 | |||
| 38 | 2 | 1; # End of Dev::Util::Const | |
| 39 | |||
| 40 | =pod | ||
| 41 | |||
| 42 | =encoding utf-8 | ||
| 43 | |||
| 44 | =head1 NAME | ||
| 45 | |||
| 46 | Dev::Util::Const - Defines named constants as Readonly. | ||
| 47 | |||
| 48 | =head1 VERSION | ||
| 49 | |||
| 50 | Version v2.19.42 | ||
| 51 | |||
| 52 | =head1 SYNOPSIS | ||
| 53 | |||
| 54 | Dev::Util::Const - Defines named constants as Readonly, based on best practices. | ||
| 55 | This idea comes from B<Perl Best Practices> by Damian Conway I<pg. 56>. | ||
| 56 | |||
| 57 | use Dev::Util::Const; | ||
| 58 | my $empty_var = $EMPTY_STR; | ||
| 59 | my $comma = $COMMA; | ||
| 60 | |||
| 61 | use Dev::Util::Const qw(:named_constants); | ||
| 62 | my $space = $SPACE; | ||
| 63 | my $single_quote = $SINGLE_QUOTE; | ||
| 64 | |||
| 65 | use Dev::Util::Const qw($DOUBLE_QUOTE); # only import a single constant. | ||
| 66 | my $double_quote = $DOUBLE_QUOTE; | ||
| 67 | |||
| 68 | =head2 Note | ||
| 69 | |||
| 70 | The purpose of this module is to define the named constants. As such the constants | ||
| 71 | are exported by default. | ||
| 72 | |||
| 73 | The second and third examples above work but at the present time are superfluous. They | ||
| 74 | are retained for future expansion. | ||
| 75 | |||
| 76 | =head1 EXPORT_TAGS | ||
| 77 | |||
| 78 | =over 4 | ||
| 79 | |||
| 80 | =item B<:named_constants> | ||
| 81 | |||
| 82 | =over 8 | ||
| 83 | |||
| 84 | =item $EMPTY_STR | ||
| 85 | |||
| 86 | =item $SPACE | ||
| 87 | |||
| 88 | =item $SINGLE_QUOTE | ||
| 89 | |||
| 90 | =item $DOUBLE_QUOTE | ||
| 91 | |||
| 92 | =item $COMMA | ||
| 93 | |||
| 94 | =back | ||
| 95 | |||
| 96 | =back | ||
| 97 | |||
| 98 | =head1 CONSTANTS | ||
| 99 | |||
| 100 | These constants are defined as readonly: | ||
| 101 | |||
| 102 | =over 4 | ||
| 103 | |||
| 104 | =item C<$EMPTY_STR = q{};> | ||
| 105 | |||
| 106 | =item C<$SPACE = q{ };> | ||
| 107 | |||
| 108 | =item C<$SINGLE_QUOTE = q{'};> | ||
| 109 | |||
| 110 | =item C<$DOUBLE_QUOTE = q{"};> | ||
| 111 | |||
| 112 | =item C<$COMMA = q{,};> | ||
| 113 | |||
| 114 | =back | ||
| 115 | |||
| 116 | =head1 SUBROUTINES | ||
| 117 | |||
| 118 | There are no public subroutines. | ||
| 119 | |||
| 120 | =head1 AUTHOR | ||
| 121 | |||
| 122 | Matt Martini, C<< <matt at imaginarywave.com> >> | ||
| 123 | |||
| 124 | =head1 BUGS | ||
| 125 | |||
| 126 | Please report any bugs or feature requests to C<bug-dev-util at rt.cpan.org>, or through | ||
| 127 | the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dev-Util>. I will | ||
| 128 | be notified, and then you'll automatically be notified of progress on your bug as I make changes. | ||
| 129 | |||
| 130 | =head1 SUPPORT | ||
| 131 | |||
| 132 | You can find documentation for this module with the perldoc command. | ||
| 133 | |||
| 134 | perldoc Dev::Util::Const | ||
| 135 | |||
| 136 | You can also look for information at: | ||
| 137 | |||
| 138 | =over 4 | ||
| 139 | |||
| 140 | =item * RT: CPAN's request tracker (report bugs here) | ||
| 141 | |||
| 142 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Dev-Util> | ||
| 143 | |||
| 144 | =item * Search CPAN | ||
| 145 | |||
| 146 | L<https://metacpan.org/release/Dev-Util> | ||
| 147 | |||
| 148 | =back | ||
| 149 | |||
| 150 | =head1 ACKNOWLEDGMENTS | ||
| 151 | |||
| 152 | =head1 LICENSE AND COPYRIGHT | ||
| 153 | |||
| 154 | This software is Copyright © 2024-2026 by Matt Martini. | ||
| 155 | |||
| 156 | This is free software, licensed under: | ||
| 157 | |||
| 158 | The GNU General Public License, Version 3, June 2007 | ||
| 159 | |||
| 160 | =cut | ||
| 161 | |||
| 162 | __END__ | ||