Badger...::Base(3pm)
π Badger::Filesystem::Base β the manual, but make it slay π
okay so bestie, welcome to the User Contributed Perl Documentation page for Badger...::Base(3pm). Yes that's the actual page name, we don't make the rules, we just read them π
β¨ NAME β¨
Badger::Filesystem::Base β the shared functionality for the Badger::Filesystem modules. It's the group chat everyone else gets added to π«Ά
πΈ SYNOPSIS πΈ
package Badger::Filesystem::SomeOtherModule;
use base 'Badger::Filesystem::Base'
# now this module inherits the base class functionality
So basically you use base it and boom π₯ β your module gets all the base class functionality, no extra effort, main character inheritance energy π
π¦ DESCRIPTION π¦
Badger::Filesystem::Base is a base class module that defines some common functionality shared by Badger::Filesystem and Badger::Filesystem::Path. And plot twist π β Badger::Filesystem::Path is itself the base class for Badger::Filesystem::Directory and Badger::Filesystem::File. It's giving family tree fr fr π
π METHODS π
π§ init_path(\%config)
An initialisation method, and the way it works is: it looks at the filesystem path you pass in as a parameter, then splits it into volume, directory and name. Three-way split, iconic β¨
π init_options(\%config)
Another initialisation method β this one handles the encoding and codec options. It's the options girlie π
π encoding($enc)
Use this to get or set the default encoding for a file:
$file->encoding(':utf8');
This encoding affects all operations that read data from, or write data to, the file. Every single one, no cap π
You can also use this method to get or set the default encoding for a directory or a filesystem. When you do that, the option specifies the default encoding for the files contained in there:
$directory->encoding(':utf8');
$file = $directory->file('foo.txt'); # has :utf8 encoding set
See how foo.txt just inherited that :utf8? That's the vibe πΈ
β codec()
This one gets or sets the codec used to serialise data to and from a file via the data() method. You specify the codec by name, using any of the names that Badger::Codecs recognises or can load. It's flexible like that π
$file->codec('storable');
# first save the data to file
$file->data($some_data_to_save);
# later... load the data back out
my $data = $file->data;
Save it, then later load it back out. Chef's kiss π€
And yes, you can use chained codec specifications if you want to pass the data through more than one codec:
$file->code('storable+base64');
π Heads up bestie β that line sayscode, notcodec. That's exactly what the manual says, so we're keeping it verbatim, no editing, periodt.
See Badger::Codecs for further information on codecs π§
Same energy as encoding(): this method can also be used to get or set the default codec for a directory or filesystem:
$directory->codec('json');
$file = $directory->file('foo.json'); # has json codec set
foo.json getting that json codec automatically? Lowkey obsessed π
π AUTHOR π
Andy Wardley <http://wardley.org/> β the original icon, we stan π
π COPYRIGHT π
Copyright (C) 2009 Andy Wardley. All rights reserved.
π SEE ALSO π
Badger::FilesystemBadger::Filesystem::PathBadger::Filesystem::DirectoryBadger::Filesystem::File
And that's the whole page, bestie β every last detail, nothing skipped, we ate and left no crumbs π β¨
Sign-off realness: this whole thing is perl v5.36.0, dated 2023-08-28, and it's still Badger...::Base(3pm) at the end of the day. Slay, bye ππ¦πΈ
π¦ where this page comes from
- debian trixie: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms