#!/usr/bin/perl -w use strict; use Fcntl qw(:flock); use constant MONTHS => qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); use constant DATE_RX => qr#(\d+)/(\d+)/(\d+) at (\d\d:\d\d:\d\d)#; print "Content-type: text/html\n\n"; my $boarddir = './yabb/Boards'; my $boardurl = '/cgi-bin/yabb/YaBB.pl'; chdir $boarddir or die "Cannot chdir to $boarddir: $!"; my @files = do { opendir my $dir, "." or die ("Cannot open Boards directory $!"); grep /\.txt\z/, readdir $dir; }; sub parse_time { require HTTP::Date; return unless @_ == 4; my $time = "$_[1] ".(MONTHS)[$_[0]-1]." $_[2] $_[3] GMT"; return ($time, HTTP::Date::str2time($time)); } my @data; for my $file (@files) { open my $fh, "<", $file or die "Cannot open file $file: $!"; flock $fh, LOCK_SH; my ($board) = $file =~ /(\w+)\./; while (<$fh>) { my ($id, $name, $user, $email, $datetime) = split /\|/; my ($time, $utime) = parse_date($datetime =~ DATE_RX); push @data, [ $utime, $board, $id, $name, $time ] if defined $utime; } } my @link = @{ sort { $a->[0] <=> $b->[0] } @data)[0] || [] }; printf qq{<div id="lastmbpost"><a href="%s?board=%d;action=display;num=%d +;start=1">%s</a><br />was updated on %s</div>}, $boardurl, @link[1..4];
Untested.

Makeshifts last the longest.


In reply to Re: Display most recent post to a YaBB forum by Aristotle
in thread Display most recent post to a YaBB forum by newrisedesigns

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.