Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Programming > Libraries

    Chess::PGN::Parse 0.19

    Download button

    No screenshots available
    Downloads: 686  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Excellent (5.0/5)
    1 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Giuseppe Maxia | More programs
    Perl Artistic License / FREE
    August 1st, 2007, 10:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Chess::PGN::Parse description

    Chess::PGN::Parse is a Perl module that reads and parses PGN (Portable Game Notation) Chess files.

    Chess::PGN::Parse is a Perl module that reads and parses PGN (Portable Game Notation) Chess files.

    SYNOPSIS

    use Chess::PGN::Parse;
    use English qw( -no_match_vars );
    my $pgnfile = "kk_2001.pgn";
    my $pgn = new Chess::PGN::Parse $pgnfile
    or die "can't open $pgnfilen";
    while ($pgn->read_game()) {
    print $pgn->white, ", " , $pgn->black, ", ",
    $pgn->result, ", ",
    $pgn->game, "n";
    }


    use Chess::PGN::Parse;
    my $text ="";
    {
    local $INPUT_RECORD_SEPARATOR = undef;
    open PGN "< $pgnfile" or die;
    $text = ;
    close $text;
    }
    # reads from string instead of a file
    my $pgn = new Chess::PGN::Parse undef, $text;
    while ($pgn->read_game()) {
    print $pgn->white, ", " , $pgn->black, ", ",
    $pgn->result, ", ",
    $pgn->game, "n";
    }

    use Chess::PGN::Parse;
    my $pgnfile = "kk_2001.pgn";
    my $pgn = new Chess::PGN::Parse $pgnfile
    or die "can't open $pgnfilen";
    my @games = $pgn->smart_read_all();

    Chess::PGN::Parse offers a range of methods to read and manipulate Portable Game Notation files. PGN files contain chess games produced by chess programs following a standard format (http://www.schachprobleme.de/chessml/faq/pgn/). It is among the preferred means of chess games distribution. Being a public, well established standard, PGN is understood by many chess archive programs. Parsing simple PGN files is not difficult. However, dealing with some of the intricacies of the Standard is less than trivial. This module offers a clean handle toward reading and parsing complex PGN files.

    A PGN file has several tags, which are key/values pairs at the header of each game, in the format [key "value"]
    After the header, the game follows. A string of numbered chess moves, optionally interrupted by braced comments and recursive parenthesized variants and comments. While dealing with simple braced comments is straightforward, parsing nested comments can give you more than a headache.

    Chess::PGN::Parse most immediate methods are: read_game() reads one game, separating the tags and the game text.

    parse_game() parse the current game, and stores the moves into an
    array and optionally saves the comments into an array of hashes
    for furter usage. It can deal with nested comments and recursive
    variations.

    quick_parse_game() Same as the above, but doesn't save the comments,
    which are just stripped from the text. It can't deal with nested
    comments. Should be the preferred method when we know that we are
    dealing with simple PGNs.

    smart_parse_game() Best of the above methods. A preliminary check
    will call parse_game() or quick_parse_game(), depending on the
    presence of nested comments in the game.

    read_all(), quick_read_all(), smart_read_all() will read all the records
    in the current PGN file and return an array of hashes with all the
    parsed details from the games.

    Requirements:

    · Perl



    Product's homepage

      


    TAGS:

    PGN parser | PGN chess | Portable Game Notation | Chess::PGN::Parse | PGN | chess



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM