#!/usr/local/bin/perl # # structtest - example of a call to WebFetch::PerlStruct # # Copyright (c) 1999 Ian Kluft. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the # same terms as Perl itself. # use Carp; use WebFetch::PerlStruct; $content = [ { "url" => "http://www.svlug.org/news.shtml#19990410-000", "title" => "EHeadlines puts SVLUG news on your Enlightenment desktop" }, { "url" => "http://www.svlug.org/news.shtml#19990408-000", "title" => "SVLUG has released WebFetch 0.04" }, { "url" => "http://www.svlug.org/news.shtml#19990402-000", "title" => "comp.os.linux.announce and CNN Linux news added to SVLUG home page" }, { "url" => "http://www.svlug.org/news.shtml#19990330-000", "title" => "SVLUG Editorial on Competition for DNS" }, { "url" => "http://www.svlug.org/news.shtml#19990329-000", "title" => "Linux 2.2.5 released" }, { "url" => "http://www.svlug.org/news.shtml#19990310-000", "title" => "Marc Merlin's LinuxWorld Report and Pictures" } ]; $obj = new WebFetch::PerlStruct ( "content" => $content, "dir" => ".", "file" => "perlstruct.html", # present of export causes a WebFetch export file to be made "export" => "ps-export.txt", # presence of ns_export causes a MyNetscape export file to be made "ns_export" => "ps-ns-export.txt", "ns_site_title" => "Example", "ns_site_link" => "http://www.svlug.org/", "ns_site_desc" => "Silicon Valley Linux User Group" ); if ( $@ ) { croak "WebFetch: error: $@\n"; } $result = $obj->save(); if ( ! $result ) { my $savable; foreach $savable ( @{$obj->{savable}}) { (ref $savable eq "HASH") or next; if ( defined $savable->{error}) { print STDERR "WebFetch: (in " .$obj->{dir}.") error saving " .$savable->{file}.": " .$savable->{error}."\n" } } } $result ? 0 : 1;