![]() |
![]()
| ![]() |
![]()
NAMEBadger::Constants - defines constants for other Badger modules SYNOPSISuse Badger::Constants 'HASH'; if (ref $something eq HASH) { # rejoice! No need to quote the word 'HASH' } DESCRIPTIONThis module defines a number of constants used by other "Badger" modules. They can be imported into the caller's namespace by naming them as options to the "use Badger::Constants" statement: use Badger::Constants 'HASH'; print HASH; # HASH Alternatively, one of the tagset identifiers may be specified to import different sets of constants. use Badger::Constants ':types'; print HASH; # HASH EXPORTABLE CONSTANTSCONSTANTSSet to "Badger::Constants". SCALARThe literal word "SCALAR", typically used for testing references. if (ref $data eq SCALAR) { ... } ARRAYThe literal word "ARRAY", typically used for testing references. if (ref $data eq ARRAY) { ... } HASHThe literal word "HASH", typically used for testing references. if (ref $data eq HASH) { ... } CODEThe literal word "CODE", typically used for testing references. if (ref $data eq CODE) { ... } GLOBThe literal word "GLOB", typically used for testing references. if (ref $data eq GLOB) { ... } REGEXThe literal word "Regexp", typically used for testing references. if (ref $data eq REGEX) { ... } FALSEA false value (0) TRUEA true value (1) OFFA generic flag used to disable things (0). ONA generic flag used to enable things (1). ALLThe literal string "all". NONEThe literal string "none". DEFAULTThe literal string "default". WARNThe literal string "warn". LASTThe value -1, used to index the last item in an array. $array[LAST]; CRLFAn unambiguous carriage return and newline sequence: "\015\012" PKGAn alias for the "::" symbol used to delimiter Perl packages. Typically used to construct symbol references. use Badger::Constants 'PKG'; use constant EXAMPLE => 'EXAMPLE'; my $var = ${ $pkg.PKG.EXAMPLE }; # same as: ${"${pkg}::EXAMPLE"} DOTAn alias for a dot ".". REFSThe literal string "refs". Typically used like so: no strict REFS; ONCEThe literal string "once". Typically used like so: no warnings ONCE; BLANKAn empty string. How much more blank could this be? And the answer is none. None more blank. SPACEA single space character. Not to be confused with the three dimensional fabric of reality that it happens to share a name with. SLASHA forward slash as used to separate path segments in URIs and filesystem paths on sane operating systems. DELIMITERA regular expression used to split whitespace delimited tokens. Also accepts commas with optional trailing whitespace as a delimiter. $names = [ split DELIMITER, $names ] unless ref $names eq ARRAY; WILDCARDA regular expression used to match strings containing the "*" or "?" wildcard characters. if ($path =~ WILDCARD) { # do something... } UTF8The literal string "utf8". JSONThe literal string "json". YAMLThe literal string "yaml". LOADEDContains the literal string "BADGER_LOADED". The Badger::Class module uses it to define the $BADGER_LOADED variable in any modules that it loads. EXPORTABLE TAG SETSThe following tag sets and associated constants are defined: :typesSCALAR HASH ARRAY CODE REGEX :valuesFALSE TRUE OFF ON ALL NONE DEFAULT :allAll the constants. AUTHORAndy Wardley <http://wardley.org/> COPYRIGHTCopyright (C) 1996-2009 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSOSee Badger::Exporter for more information on exporting variables.
|