Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stag-grep(1p) [debian man page]

STAG-GREP(1p)						User Contributed Perl Documentation					     STAG-GREP(1p)

NAME
stag-grep - filters a stag file (xml, itext, sxpr) for nodes of interest SYNOPSIS
stag-grep person -q name=fred file1.xml stag-grep person 'sub {shift->get_name =~ /^A*/}' file1.xml stag-grep -p My::Foo -w sxpr record 'sub{..}' file2 USAGE
stag-grep [-p|parser PARSER] [-w|writer WRITER] NODE -q tag=val FILE stag-grep [-p|parser PARSER] [-w|writer WRITER] NODE SUB FILE stag-grep [-p|parser PARSER] [-w|writer WRITER] NODE -f PERLFILE FILE DESCRIPTION
parsers an input file using the specified parser (which may be a built in stag parser, such as xml) and filters the resulting stag tree according to a user-supplied subroutine, writing out only the nodes/elements that pass the test. the parser is event based, so it should be able to handle large files (although if the node you parse is large, it will take up more memory) ARGUMENTS
-p|parser FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module xml assumed as default -w|writer FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module -c|count prints the number of nodes that pass the test -filterfile|f a file containing a perl subroutine (in place of the SUB argument) -q|query TAG1=VAL1 -q|query TAG2=VAL2 ... -q|query TAGN=VALN filters based on the field TAG other operators can be used too - eg <, <=, etc multiple q arguments can be passed in for more complex operations, pass in your own subroutine, see below SUB a perl subroutine. this subroutine is evaluated evry time NODE is encountered - the stag object for NODE is passed into the subroutine. if the subroutine passes, the node will be passed to the writer for display NODE the name of the node/element we are filtering on FILE the file to be parser. If no parser option is supplied, this is assumed to a be a stag compatible syntax (xml, sxpr or itext); otherwise you should parse in a parser name or a parser module that throws stag events SEE ALSO
Data::Stag perl v5.10.0 2008-12-23 STAG-GREP(1p)

Check Out this Related Man Page

STAG-PARSE(1p)						User Contributed Perl Documentation					    STAG-PARSE(1p)

NAME
stag-parse - parses a file and fires events (e.g. sxpr to xml) SYNOPSIS
# convert XML to IText stag-parse -p xml -w itext file1.xml file2.xml # use a custom parser/generator and a custom writer/generator stag-parse -p MyMod::MyParser -w MyMod::MyWriter file.txt DESCRIPTION
script wrapper for the Data::Stag modules feeds in files into a parser object that generates nestarray events, and feeds the events into a handler/writer class ARGUMENTS
-p|parser FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module this is the class that parsers the input file(s) and generates stag events xml assumed as default -w|writer FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module this is the class that catches the events thrown by the parser; it can be any class, but the class is typically a writer xml assumed as default -o|out FILE the writer will use this file (defaults to STDOUT) -e|errf FILE file to store parse error handler output -errhandler FORMAT/MODULE FORMAT is one of xml, sxpr or itext, or the name of a perl module all parse error events go to this module -r|root NODE_NAME if this is specified, NODE_NAME becomes the root of the stag tree, and anything that was previously the root is placed below this. this happens automatically if more than one file is parsed (because there can only be one tree root) -color Works only if the output handler is able to provide ASCII-colors (currently supported for itext and xml) SEE ALSO
Data::Stag This script is a wrapper for the method Data::Stag->parse() perl v5.10.0 2008-12-23 STAG-PARSE(1p)
Man Page