#!/usr/bin/perl
# massage IDEAS bocoec listings
print "\nbcecweblist v1.0.1\n\n";
print "C F Baum  Oct 2009\n\n";
print "\nMust run on fmwww with sudo!\n";
use LWP::Simple;
use Text::Wrap;
$outf=">/fmwww0/ec-p/ecweblistings/curpubs.php";
use open OUT => ':utf8';
open(OUT,$outf) || die "Cannot open $outf for output";
print OUT "\x{FEFF}\n"; # utf BOM]
print OUT "<?php\n\$bookmark=\"Boston College Department of Economics\";\n require(\"http://fmwww.bc.edu/ec/ec_top.inc\");\n ?>";
print OUT "<h2>Recent published articles by BC EC authors listed in RePEc</h2>\n";
$rslt = getstore("http://ideas.repec.org/d/debocus.html","publist.html");
print "$rslt\n";
open(IN, "<:encoding(UTF-8)", "publist.html") || die "Cannot open publist.html";
$chunk="";
while (<IN>) {
 $chop;
 $chunk=$chunk.$_;
 };
$chunk =~ s/\n/ /ig;
$chunk =~ s/\r/ /ig;
($jnl) = ($chunk =~ /.+<h3>Journal articles(.+?)<h3>Books/igm);
$jnl =~ s!HREF=!HREF=http://ideas.repec.org!igm;
$jnl =~ s!<LI>!<p><LI>!igm;
(@yrs) = split("<OL>",$jnl);
$nyrs = @yrs;
print "$nyrs\n";
$i = 0;
foreach $yr (@yrs) {
	$i = $i + 1;
# current year
	if ($i == 2) {
			print OUT "\n $yr ";
	}
# previous year -- suppress
#	if ($i == 3) {
#			print OUT "\n $yr ";
#	}
}
print OUT "\n &nbsp; <p> &nbsp; <p> &nbsp; Note: many of these articles are available as <a href=\"/ec/research.php\">BC Working Papers. <\/a> &nbsp;<p>&nbsp;<p>\n <?php \n require(\"http://fmwww.bc.edu/ec/ec_bot.inc\"); \n ?>";
exit;
__END__
