Badger(3pm)

πŸ“¦
version 0.16 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu resolute

πŸ’– NAME πŸ’–

Badger β€” the Perl Application Programming Toolkit. That's it, that's the whole vibe: it's a toolkit, it's Perl, it's for apps. πŸ¦‹


✨ SYNOPSIS ✨

okay so here's the main character entrance, bestie πŸ’…

use Badger
    lib        => '../lib',     # like 'use lib' but relative to $Bin
    Filesystem => 'File Dir',   # import from Badger::Filesystem

use Badger
    Filesystem => 'Dir File',
    Utils      => 'numlike textlike',
    Constants  => 'ARRAY HASH',
    Codecs     => [codec => 'base64'];

and that whole thing is literally the same as doing this the long way around:

use Badger;
use Badger::Filesystem 'Dir File';
use Badger::Utils      'numlike textlike',
use Badger::Constants  'ARRAY HASH',
use Badger::Codecs      codec => 'base64';

🌸 DESCRIPTION 🌸

The Badger toolkit is a collection of Perl modules designed to simplify the process of building object-oriented Perl applications. It hands you a whole set of foundation classes so you can quickly build robust and reliable systems that are β€” and I quote β€” simple, sexy and scalable. πŸ˜ŒπŸ’… If you want the full lore drop, go read "Badger::Intro" for further information.

The Badger module itself is a front-end to other Badger modules. Basically it's the group chat and all the other modules are the members 🫢. You can use it to import any of the exportable items from any other Badger module β€” just specify the module name, minus the Badger:: prefix, as a load option.

For example:

use Badger
    Filesystem => 'Dir File',
    Utils      => 'numlike textlike',
    Constants  => 'ARRAY HASH',
    Codecs     => [codec => 'base64'];

This is equivalent to:

use Badger;
use Badger::Filesystem 'Dir File';
use Badger::Utils      'numlike textlike',
use Badger::Constants  'ARRAY HASH',
use Badger::Codecs      codec => 'base64';
⚠️ important note, don't skip this one: multiple arguments for a module should be defined as a list reference. That's the rule. no cap.
use Badger
    ...etc...
    Codecs => [codec => 'base64'];

This is equivalent to:

use Badger::Codecs [codec => 'base64'];

Which is also equivalent to:

use Badger::Codecs codec => 'base64';

πŸŽ€ EXPORT HOOKS πŸŽ€

The Badger module can import items from any other Badger::* module, exactly like in the examples up there πŸ‘†. And there's one extra export hook provided, and she is iconic:

lib

This performs the same task as use lib in adding a directory to your @INC module include path. BUT β€” and this is the part that slays β€” there are two differences. First, you can specify a directory relative to the directory in which the script exists. 🧚

use Badger lib => '../perl/lib';

For example, consider a directory layout like this:

my_project/
    bin/
        example_script.pl
    perl/
        lib/
            My/
                Module.pm
        t/
            my_module.t

The my_project/example_script.pl can be written like so:

#!/usr/bin/perl

use Badger lib => '../perl/lib';
use My::Module;

# your code here...

This adds my_project/perl/lib to the include path so that the "My::Module" module can be correctly located. It is equivalent to the following code using the FindBin module:

#!/usr/bin/perl

use FindBin '$Bin';
use lib "$Bin/../perl/lib";
use My::Module;

πŸ‘‘ METHODS πŸ‘‘

hub()

Returns a Badger::Hub object. that's the whole thing, she's simple, she's powerful. 🫢

codec()

Delegates to the Badger::Hub codec() method to return a Badger::Codec object.

my $base64  = Badger->codec('base64');
my $encoded = $base64->encode($uncoded);
my $decoded = $base64->decode($encoded);

encode then decode, a full circle moment. πŸ”₯

config()

Delegates to the Badger::Hub codec() method to return a Badger::Config object. Heads up though: this is still experimental. πŸ™ˆ Treat her gently.


⭐ TODO ⭐

Other methods like codec() to access different Badger modules. These should be generated dynamically on demand. (future plans, bestie β€” manifesting it ✨)


πŸ’€ BUGS πŸ’€

Please report bugs or (preferably) send pull requests to merge bug fixes via the github repository: <https://github.com/abw/Badger>. Not me asking you to send a PR instead of a bug report 😭 but fr fr, fixes are welcome.


🌈 AUTHOR 🌈

Andy Wardley <http://wardley.org/>.

With contributions from Brad Bowman and Michael Grubb, and code, inspiration and insight borrowed from many other module authors. shoutout to everyone, no gatekeeping in this house πŸ’œ


Copyright (C) 1996-2012 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. periodt. πŸ’…


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie 🫢 this was Badger(3pm), part of the User Contributed Perl Documentation, shipped with perl v5.36.0 and dated 2023-08-28. go build something sexy and scalable. mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from