STAG-HANDLE(1p)

πŸ“¦
version 0.14 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– 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, -m PERLMODULE β€” a module that is used to transform the input events. bestie, this module should inherit from Data::Stag::BaseHandler ✨
  • -unit, -u NODE_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, -w WRITER β€” writer for the final transformed tree; can be xml, sxpr or itext πŸ¦‹
  • -module, -m MODULE β€” perl modules for handling events πŸ’œ
  • -codefile, -c FILE β€” a file containing a perlhashref containing event handlers β€” see below πŸ‘€
  • -sub, -s PERL β€” a perl hashref containing handlers πŸ“
  • -trap, -t ELEMENT=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