Data::...Writer(3pm)
π¦ Data::Stag::Writer π¦
hiii bestie π so you're looking at the manual page for Data::Stag::Writer, which lives in the User Contributed Perl Documentation corner of the universe. ngl this one is a base class, which means you do not use it directly β you inherit from it and it does the vibes for you. let's get into it β¨
πΈ NAME πΈ
Data::Stag::Writer β the base class for all Writers. like, every single one. it's giving founding mother energy π
β¨ SYNOPSIS β¨
# Abstract class - do not use directly
package MyOutputter;
use base qw(Data::Stag::Writer);
sub e_foo {
my ($self, $foo) = @_;
$self->writef("data1: %s\n", $foo->get_data1);
return;
}
π¨ ok real talk: that comment says Abstract class - do not use directly. that is not a suggestion, bestie. that is the law. you subclass it, you don't touch it raw π
π DESCRIPTION π
it's a base mixin class for all writers. that's it, that's the description. she's short, she's iconic, she said what she said π
π§ INHERITANCE π§
this one inherits from L<Data::Stag::BaseHandler> β so all that handler energy is already in the building, no cap π«Ά
π PUBLIC METHODS - π
okay this is the main character section, get comfy π
π new
Title: new
Args: [fn str], [fh FILEHANDLE]
Return: L<Data::Stag::BaseHandler>
Example: $w = MyWriter->new(-fh=>$fh);
returns the tree that was built from all uncaught events π³
lowkey obsessed with the fact that it hands you back a Data::Stag::BaseHandler. that's the return type, fr fr.
π file
Title: file
Args: filename str
Returns: filename str
Example: $handler->file("my_output_file.txt");
setting this will cause all output to be diverted to this file; the file will be overwritten by default β οΈ so like, don't point it at your diary. the filehandle will not be opened unless any events are thrown.
for more fine-grained control, use $handler->fh() π
π fh
Title: fh
Args: filehandle FH
Returns: filehandle FH
Example: $handler->fh(\*STDOUT);
gets/sets the output filehandle for the writer. that's the whole thing. simple, clean, slay β¨
π safe_fh
Title: safe_fh
Type: PROTECTED
Args: filehandle FH
Returns: filehandle FH
Example: $handler->fh(\*STDOUT);
it's literally fh(), but it makes sure that the filehandle is initialized first. no uninitialized-filehandle jumpscare π«Ά
you should use this if you are overriding this class. that's not a vibe check, that's an instruction π
π write
Title: write
Type: PROTECTED
Args: message str
Returns:
Example: $self->write($stag->get_blah);
writes output π
to be used by classes that subclass this one. yes, that means you, bestie.
note that Returns: is just... empty. she gives nothing back. she's a giver in the writing sense only π
π writef
Title: writef
as write, analogous to printf π
π use_color
Usage -
Returns -
Args -
that's it. that's the whole entry. three little lines, zero elaboration. she's mysterious, she's enigmatic, she's an icon ππ
π and that's the page π
if you were looking for more detail on use_color, bestie, so was I. sometimes the documentation is a vibe, not a manual π
sending you off with love π this page is from perl v5.34.0, dated 2022-06-12. mwah, go write something iconic, and remember: subclass it, don't use it directly πβ¨π
π¦ where this page comes from
- debian bookworm: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libdata-stag-perl 0.14-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms