#!/usr/local/bin/perl # + gettepco/ # + gettepco.pl # + c/ # | + 20110324.csv # | # + h/ # + max # + use mkdir("c"); mkdir("h"); $time = time(); $time -= 60*60; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); $year += 1900; $mon += 1; use LWP::Simple; $csv = get('http://www.tepco.co.jp/forecast/html/images/juyo-j.csv'); $csvfile = sprintf("c/%04d%02d%02d.csv", $year, $mon, $mday, $csvfile); open(FOUT, ">$csvfile") || die "cannot open [${name}]."; print FOUT $csv; close(FOUT); # 2011/3/24,0:00,2920,2770 $key = sprintf("^%04d/%d/%d,%d:%02d,([0-9]+),([0-9]+)", $year, $mon, $mday, $hour); open(FIN, $csvfile) || die "cannot open [${name}]."; while () { if ( /${key}/ ) { $max = $1; $use = $2; open(FOUT, ">h/max"); print FOUT $max; close(FOUT); open(FOUT, ">h/use"); print FOUT $use; close(FOUT); last; } }