Badger::Constants

NAME

Top Close Open

Badger::Constants - defines constants for other Badger modules

SYNOPSIS

Top Close Open
use Badger::Constants 'HASH';

if (ref $something eq HASH) {
    # rejoice!  No need to quote the word 'HASH'
}

DESCRIPTION

Top Close Open

This 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 CONSTANTS

Top Close Open

CONSTANTS

Top Close Open

Set to Badger::Constants.

SCALAR

Top Close Open

The literal word SCALAR, typically used for testing references.

if (ref $data eq SCALAR) {
    ...
}

ARRAY

Top Close Open

The literal word ARRAY, typically used for testing references.

if (ref $data eq ARRAY) {
    ...
}

HASH

Top Close Open

The literal word HASH, typically used for testing references.

if (ref $data eq HASH) {
    ...
}

CODE

Top Close Open

The literal word CODE, typically used for testing references.

if (ref $data eq CODE) {
    ...
}

GLOB

Top Close Open

The literal word GLOB, typically used for testing references.

if (ref $data eq GLOB) {
    ...
}

REGEX

Top Close Open

The literal word Regexp, typically used for testing references.

if (ref $data eq REGEX) {
    ...
}

FALSE

Top Close Open

A false value (0)

TRUE

Top Close Open

A true value (1)

OFF

Top Close Open

A generic flag used to disable things (0).

A generic flag used to enable things (1).

ALL

Top Close Open

The literal string all.

NONE

Top Close Open

The literal string none.

DEFAULT

Top Close Open

The literal string default.

WARN

Top Close Open

The literal string warn.

LAST

Top Close Open

The value -1, used to index the last item in an array.

$array[LAST];

CRLF

Top Close Open

An unambiguous carriage return and newline sequence: \015\012

PKG

Top Close Open

An 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"}

DOT

Top Close Open

An alias for a dot ..

REFS

Top Close Open

The literal string refs. Typically used like so:

no strict REFS;

ONCE

Top Close Open

The literal string once. Typically used like so:

no warnings ONCE;

BLANK

Top Close Open

An empty string. How much more blank could this be? And the answer is none. None more blank.

SPACE

Top Close Open

A single space character. Not to be confused with the three dimensional fabric of reality that it happens to share a name with.

SLASH

Top Close Open

A forward slash as used to separate path segments in URIs and filesystem paths on sane operating systems.

DELIMITER

Top Close Open

A 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;

WILDCARD

Top Close Open

A regular expression used to match strings containing the * or ? wildcard characters.

if ($path =~ WILDCARD) {
    # do someting...
}

UTF8

Top Close Open

The literal string utf8.

JSON

Top Close Open

The literal string json.

YAML

Top Close Open

The literal string yaml.

LOADED

Top Close Open

Contains 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 SETS

Top Close Open

The following tag sets and associated constants are defined:

:types

Top Close Open
SCALAR HASH ARRAY CODE REGEX

:values

Top Close Open
FALSE TRUE OFF ON ALL NONE DEFAULT

:all

Top Close Open

All the constants.

AUTHOR

Top Close Open

Andy Wardley http://wardley.org/

COPYRIGHT

Top Close Open

Copyright (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 ALSO

Top Close Open

See Badger::Exporter for more information on exporting variables.

Fork Me on Github