Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stone::cursor(3pm) [debian man page]

Stone::Cursor(3pm)					User Contributed Perl Documentation					Stone::Cursor(3pm)

NAME
Stone::Cursor - Traverse tags and values of a Stone SYNOPSIS
use Boulder::Store; $store = Boulder::Store->new('./soccer_teams'); my $stone = $store->get(28); $cursor = $stone->cursor; while (my ($key,$value) = $cursor->each) { print "$value: Go Bluejays! " if $key eq 'State' and $value eq 'Katonah'; } DESCRIPTION
Boulder::Cursor is a utility class that allows you to create one or more iterators across a Stone object. This is used for traversing large Stone objects in order to identify or modify portions of the record. CLASS METHODS Boulder::Cursor->new($stone) Return a new Boulder::Cursor over the specified Stone object. This will return an error if the object is not a Stone or a descendent. This method is usually not called directly, but rather indirectly via the Stone cursor() method: my $cursor = $stone->cursor; OBJECT METHODS $cursor->each() Iterate over the attached Stone. Each iteration will return a two-valued list consisting of a tag path and a value. The tag path is of a form that can be used with Stone::index() (in fact, a cursor is used internally to implement the Stone::dump() method. When the end of the Stone is reached, "each()" will return an empty list, after which it will start over again from the beginning. If you attempt to insert or delete from the stone while iterating over it, all attached cursors will reset to the beginnning. For example: $cursor = $s->cursor; while (($key,$value) = $cursor->each) { print "$value: BOW WOW! " if $key=~/pet/; } $cursor->reset() This resets the cursor back to the beginning of the associated Stone. AUTHOR
Lincoln D. Stein <lstein@cshl.org>. COPYRIGHT
Copyright 1997-1999, Cold Spring Harbor Laboratory, Cold Spring Harbor NY. This module can be used and distributed on the same terms as Perl itself. SEE ALSO
Boulder, Stone perl v5.10.1 2011-03-05 Stone::Cursor(3pm)

Check Out this Related Man Page

Boulder::XML(3pm)					User Contributed Perl Documentation					 Boulder::XML(3pm)

NAME
Boulder::XML - XML format input/output for Boulder streams SYNOPSIS
use Boulder::XML; $stream = Boulder::XML->newFh; while ($stone = <$stream>) { print $stream $stone; } DESCRIPTION
Boulder::XML generates BoulderIO streams from XML files and/or streams. It is also able to output Boulder Stones in XML format. Its semantics are similar to those of Boulder::Stream, except that there is never any pass-through behavior. Because XML was not designed for streaming, some care must be taken when reading an XML document into a series of Stones. Consider this XML document: <?xml version="1.0" standalone="yes"?> <Paper> <Author>Lincoln Stein</Author> <Author>Jean Siao</Author> <Date>September 29, 1999</Date> <Copyright copyrighted="yes">1999 Lincoln Stein</Copright> <Abstract> This is the abstract. It is not anything very fancy, but it will do. </Abstract> <Citation> <Author>Fitchberg J</Author> <Journal>Journal of Irreproducible Results</Journal> <Volume>23</Volume> <Year>1998</Volume> </Citation> <Citation> <Author>Clemenson V</Author> <Journal>Ecumenica</Journal> <Volume>10</Volume> <Year>1968</Volume> </Citation> <Citation> <Author>Ruggles M</Author> <Journal>Journal of Aesthetic Surgery</Journal> <Volume>10</Volume> <Year>1999</Volume> </Citation> </Paper> Ordinarily the document will be construed as a single Paper tag containing subtags Author, Date, Copyright, Abstract, and so on. However it might be desirable to fetch out just the citation tags as a series of Stones. In this case, you can declare Citation to be the top level tag by passing the -tag argument to new(). Now calling get() will return each of the three Citation sections in turn. If no tag is explicitly declared to be the top level tag, then Boulder::XML will take the first tag it sees in the document. It is possible to stream XML files. You can either separate them into separate documents and use the automatic ARGV processing features of the BoulderIO library, or separate the XML documents using a delimiter string similar to the delimiters used in MIME multipart documents. By default, BoulderIO uses a delimiter of <!--Boulder::XML-->. This is not a general XML parsing engine! Instead, it is a way to represent BoulderIO tag/value streams in XML format. The module uses XML::Parser to parse the XML streams, and therefore any syntactic error in the stream can cause the XML parser to quit with an error. Another thing to be aware of is that there are certain XML constructions that will not translate into BoulderIO format, specifically free text that contains embedded tags. This is OK: <Author>Jean Siao</Author> but this is not: <Author>The <Emphatic>extremely illustrious</Emphatic> Jean Siao</Author> In BoulderIO format, tags can contain other tags or text, but cannot contain a mixture of tags and text. CONSTRUCTORS $stream = Boulder::XML->new(*IN,*OUT); $stream = Boulder::XML->new(-in=>*IN, -out=>*OUT, -tag=>$tag, -delim=>$delim, -strip=>$strip) new() creates a new Boulder::XML stream that can be read from or written to. All arguments are optional. -in Filehandle to read from. If a file name is provided, will open the file. Defaults to the magic <> filehandle. -out Filehandle to write to. If a file name is provided, will open the file for writing. Defaults to STDOUT -tag The top-level XML tag to consider as the Stone record. Defaults to the first tag seen when reading from an XML file, or to E<lt>StoneE<gt> when writing to an output stream without previously having read. -delim Delimiter to use for delimiting multiple Stone objects in an XML stream. -strip If true, automatically strips leading and trailing whitespace from text contained within tags. $fh = Boulder::XML->newFh(*IN,*OUT); $fh = Boulder::XML->newFh(-in=>*IN, -out=>*OUT, -tag=>$tag, -delim=>$delim, -strip=>$strip) The newFh() constructor creates a tied filehandle that can read and write Boulder::XML streams. Invoking <> on the filehandle will perform a get(), returning a Stone object. Calling print() on the filehandle will perform a put(), writing a Stone object to output in XML format. METHODS $stone = $stream->get() $stream->put($stone) $done = $stream->done All these methods have the same semantics as the similar methods in Boulder::Stream, except that pass-through behavior doesn't apply. AUTHOR
Lincoln D. Stein <lstein@cshl.org>, Cold Spring Harbor Laboratory, Cold Spring Harbor, NY. This module can be used and distributed on the same terms as Perl itself. SEE ALSO
Boulder, Boulder::Stream, Stone perl v5.10.1 2011-03-05 Boulder::XML(3pm)
Man Page