#!/usr/local/bin/perl use strict; my $target = "ログ・ファイルへのパス"; my $baseurl = "http://www2u.biglobe.ne.jp/%7Ekyo-n/bbs/bbs.cgi"; open(FILE, $target) or die "open error!"; my @content = ; close(FILE); my $latest_mid = (split(/:/, $content[0]))[2]; chomp($latest_mid); my($items, @itemlink, @itemname, @itemcoen, @itemdesc, @itemdate, $i, $lmod); while($i < 15){ foreach(@content){ if(m/^\t?($latest_mid.*?)\n/){ my $temp = $1; my $value = "$baseurl\#$latest_mid"; $items .= qq|\t\t\t\t\n|; $itemlink[$i] = $value; $value = (split(/,/, $temp))[1] . "さんの投稿"; $itemname[$i] = $value; $value = (split(/,/, $temp))[5]; $itemcoen[$i] = $value; $value =~ s//<$1>/g; $value =~ s/(

)+//g; $value =~ s/<.*?>//g; $itemdesc[$i] = $value; $value = (split(/,/, $temp))[8]; if ($i == 0) { $lmod = $value; } my($ss, $nn, $hh, $dd, $mm, $yy) = gmtime($value + 32400); $value = sprintf("%04d-%02d-%02dT%02d:%02d:%02d+09:00", $yy + 1900, $mm + 1, $dd, $hh, $nn, $ss); $itemdate[$i] = $value; $i++; last; } } --$latest_mid; } $lmod = gmtime($lmod); $lmod =~ s/^(\w+) (\w+) (\d+) (\d\d:\d\d:\d\d) (\d{4})/$1, $3 $2 $5 $4 GMT/; my $output = <<"_HTTP-HEADER_"; Content-Type: application/xml; charset=UTF-8 Pragma: no-cache Last-Modified: $lmod _HTTP-HEADER_ $output .= <<"_RSS_"; hail2u.net - BBS http://www2u.biglobe.ne.jp/%7Ekyo-n/bbs/bbs.cgi hail2u.netのBBSから最新10件の投稿を抜き出したRSSファイルです。 $itemdate[0] _RSS_ $i = 0; for $i (0..$#itemlink){ $output .= <<"_RSS_"; _RSS_ } $output .= <<"_RSS_"; _RSS_ $i = 0; for $i (0..$#itemlink){ $output .= <<"_RSS_"; $itemname[$i] $itemlink[$i] $itemdesc[$i] $itemdate[$i] _RSS_ } $output .= <<"_RSS_"; _RSS_ print $output; exit;