David Whitcomb > Games-SGF-0.08 > Games::SGF::Util

Download:
Games-SGF-0.08.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.08   Source   Latest Release: Games-SGF-0.991

NAME ^

Games::SGF::Util - Utility pack for Games::SGF objects

VERSION ^

Version 0.08

SYNOPSIS ^

Quick summary of what the module does.

Perhaps a little code snippet.

    use Games::SGF::Util;

    my $util = new Games::SGF::Util($sgf);
    
    $util->filter( "C", undef ); # removes all comments from SGF

DISCRIPTION ^

This is a collection of useful methods for manipulating a Games::SGF object.

METHODS ^

new

  $util = new Games::SGF::Util($sgf);
  $util = new Games::SGF::Util();

This initializes a new Games::SGF::Util object. If no $sgf is given then it will create a new Games::SGF object to work with.

touch

  $util->touch(\&sub);

This will call &sub for every node in $sgf. &sub will be passed the $sgf object. any subroutines which manipulate the $sgf tree will lead to undefined behavior. The safe methods to use are:

"property" in Games::SGF
"getProperty" in Games::SGF
"setProperty" in Games::SGF
"isCompose" in Games::SGF
"isStone" in Games::SGF
"isMove" in Games::SGF
"isPoint" in Games::SGF
"compose" in Games::SGF
"stone" in Games::SGF
"move" in Games::SGF
"point" in Games::SGF
"err" in Games::SGF

filter

  $util->fiter( $tag, \&sub);

Will call &sub for every $tag which is in $sgf. &sub will be passed the tag value. The value then be reset to the return of &sub. If the return is "" the tag will be unset.

If the tag has a value list each value will be sent to $callback.

If the $callback returns undef it will not be set.

Example:

  # removes all comments that don't match m/Keep/
  $util->filter( "C", sub { return $_[0] =~ m/Keep/ ? $_[0] : ""; );

sgf

   $sgf = $util->sgf;

This returns the $sgf object associated with $util.

ALSO SEE ^

Games::SGF

AUTHOR ^

David Whitcomb, <whitcode at gmail.com>

BUGS ^

Please report any bugs or feature requests to bug-games-sgf at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-SGF. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc Games::SGF::Util

You can also look for information at:

COPYRIGHT & LICENSE ^

Copyright 2008 David Whitcomb, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.