#!/usr/bin/perl -w # Example script of the Archive::Chm module. It shows how you can get information about the # structure of a chm archive. Since extract_all dumps all the .html's to the output folder # you'll need something like this in your script in order to properly reproduce the # tree structure. # # If you need to extract the archive in a folder-tree as the one it was compiled in you can # modify this script to use extract_item and put every .html in it's designated folder. # If you only want to display the separate .html's in the structure from the TOC, you can # dump all .html's in one folder and use this script to create a kind of virtual folder for # navigating through the archive. # # It's your choice, really. :) use strict; use HTML::TreeBuilder; use Archive::Chm; #get the table of contents from the .chm archive my $chm = Archive::Chm->new("TestPrj.chm"); my $fout; open($fout, ">", "TOC.hhc") || die "Can't create file TOC.hhc"; my $item = $chm->extract_item("/Table of Contents.hhc"); # and # die "Can't extract the table of contents.\n"; print $fout, $item; close $fout; #parse the TOC file into a HTML tree my $tree = HTML::TreeBuilder->new; $tree->parse_file("TOC.hhc"); #move through the tree until we get to the start of the list #as in the first