#!/usr/bin/perl# massage IMF OCP html page directly by assembling appropriate query# 0112 1.1: remove author-workplace tag per CZprint "\nIMFocpcvt v1.11\n\n";print "C F Baum  Jan 2000\n\n";use LWP::Simple;use Text::Wrap qw(wrap $columns);$columns=68;$url="http://www.imf.org/EXTERNAL/PUBS/CAT/shortres.cfm?TITLE=&auth_ed=&subject=&ser_note=Occasional%20Papers&year=&Lang_F=English&datecrit=ALL";($page)=get($url) || die "Cannot retrieve series list";(@lines)=split /\012/,$page;$outfilename=">imfocp.rdf";open(OUT,$outfilename) || die "Cannot open $outfilename for output";$nrtem=0;$in=0;@auv={};foreach $line (@lines) {	$line =~ s!\012!!ig;	if($line =~ /Title:/ig){$in++; next};	if ($in) {($title) = ($line =~ /^.+?>(.+?)</); $in=0;}	if($line =~ /Author\/Editor:/ig){($au) = ($line =~ m!.+?\/b>(.+?)<!); 		$au =~ s! and !;!ig;			$auv[0]=$au; $auv=1;		if($au =~ m!;!) {(@auv)= split /;/, $au; $auv=@auv; } 		next};	if($line =~ /Series:/ig) {		($dum,$wpn)=($line =~ m!Paper(.+?)(\d+)!); 		if($auv==0){$auv[0]="Staff Team"; $auv=@auv;}		 print OUT "\nTemplate-Type: ReDIF-Paper 1.0\n";					print OUT "Title: $title\n";					foreach(@auv) {print OUT "Author-Name: $_\n";};					print OUT "Series: International Monetary Fund Occasional Papers\n";					print OUT "Number: $wpn\n";# could pick up date from subsidiary pages#					print OUT "Creation-Date: 19$yr\n";					print OUT "Handle: RePEc:imf:imfocp:$wpn\n";					$nrtem++;					$auv=0;					@auv={};		}	}	close OUT;	print "\ntotal templates created: $nrtem\n\n";exit;