TAP::P...Writer(3perl)
β¨ TAP::Parser::YAMLish::Writer β¨
okay bestie, gather round π this is a page from the Perl Programmers Reference Guide about TAP::Parser::YAMLish::Writer β yes that's the whole name, it's a mouthful, we love it anyway π
Version: 3.52 π
πΈ SYNOPSIS πΈ
use TAP::Parser::YAMLish::Writer;
my $data = {
one => 1,
two => 2,
three => [ 1, 2, 3 ],
};
my $yw = TAP::Parser::YAMLish::Writer->new;
# Write to an array...
$yw->write( $data, \@some_array );
# ...an open file handle...
$yw->write( $data, $some_file_handle );
# ...a string ...
$yw->write( $data, \$some_string );
# ...or a closure
$yw->write( $data, sub {
my $line = shift;
print "$line\n";
} );
like, five different ways to yeet your data out the door and every single one of them slays π
π¦ DESCRIPTION π¦
It takes a scalar, or a hash reference, or an array reference, and encodes it as YAMLish. that's the whole vibe. no notes β¨
π METHODS π
π Class Methods π
new
my $writer = TAP::Parser::YAMLish::Writer->new;
The constructor new makes you a brand new TAP::Parser::YAMLish::Writer object, fresh out the box, empty and ready to go π«Ά it creates it and hands it right back to you, periodt.
π Instance Methods π
write
$writer->write($obj, $output );
Encode a scalar, hash reference or array reference as YAML. ngl that's the main character move of this whole module π
my $writer = sub {
my $line = shift;
print SOMEFILE "$line\n";
};
my $data = {
one => 1,
two => 2,
three => [ 1, 2, 3 ],
};
my $yw = TAP::Parser::YAMLish::Writer->new;
$yw->write( $data, $writer );
The $output argument may be:
- a reference to a scalar to append YAML to π
- the handle of an open file π
- a reference to an array into which YAML will be pushed π¦
- a code reference πΈ
If you supply a code reference the subroutine will be called once for each line of output with the line as its only argument. heads up: passed lines will have no trailing newline β so if you want one, you gotta add it yourself, bestie π that's on you fr fr.
β AUTHOR β
Andy Armstrong, <andy@hexten.net>
π SEE ALSO π
YAML::Tiny, YAML, YAML::Syck, Config::Tiny, CSS::Tiny, <http://use.perl.org/~Alias/journal/29427>
go read those too, iykyk πβ¨
π COPYRIGHT π
Copyright 2007-2011 Andy Armstrong.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module. π
okay that's the whole page, no cap π this was perl v5.44.0, dated 2026-10-17, and yeah the header really does abbreviate it to TAP::P...Writer(3perl) like it's too cool to finish the word π iconic honestly, bye bestie π«ΆπΈ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND 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