STAG-HANDLE(1p)
π STAG-HANDLE β¨
okay so bestie, meet stag-handle β she's living in the User Contributed Perl Documentation, section 1p, and she is so good at what she does π«Ά
πΈ NAME πΈ
stag-handle β streams a stag file through a handler into a writer π
π¦ SYNOPSIS π¦
stag-handle -w itext -c my-handler.pl myfile.xml > processed.itext
stag-handle -w itext -p My::Parser -m My::Handler myfile.xml > processed.itext
π DESCRIPTION π
so here's the vibe: she takes a Stag compatible format (xml, sxpr or itext), turns that data into an event stream, and runs it through my-handler.pl. that's it, that's the whole main character move π
π ARGUMENTS π
-help,hβ shows this document π-module,-mPERLMODULE β a module that is used to transform the input events. bestie, this module should inherit fromData::Stag::BaseHandlerβ¨-unit,-uNODE_NAME β (you should always use this option if you specify-m, fr fr π)
this is the unit that gets passed to the handler/transformer. it will get set automatically if you use the -c, -s or -t options β no cap π
multiple units can be set, like:
-u foo -u bar -u boz
-writer,-wWRITER β writer for the final transformed tree; can bexml,sxproritextπ¦-module,-mMODULE β perl modules for handling events π-codefile,-cFILE β a file containing a perlhashref containing event handlers β see below π-sub,-sPERL β a perl hashref containing handlers π-trap,-tELEMENT=SUB β πΈ
π₯ EXAMPLES π₯
unix> cat my-handler.pl
{
person => sub {
my ($self, $person) = @_;
$person->set_fullname($person->get_firstname . ' ' .
$person->get_lastname);
$person;
},
address => sub {
my ($self, $address) = @_;
# remove addresses altogether from processed file
return;
},
}
ngl that address handler is a whole mood β it literally returns nothing so the addresses get yeeted out of the processed file entirely π
and that's the tea, bestie π«Ά this icon is running under perl v5.34.0, dated 2022-06-12, and she ate, periodt β¨ππ
π¦ 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