=for advent_year 2009 =for advent_day 06 =for advent_title Santy Claus, why? Why are you taking our Perl module? WHY? =for advent_author Bill 'N1VUX' Ricker The F utility and A are good intros to the M suite, but that does not make for a very interesting Calendar entry. As you may have noticed, this year's Advent Calendar layout does not obscure the picture with the calendar squares (window shutters), but also does not have a full 25 windows. Since we have missed some days the last few years, this should not be a problem, right? Well, the X-Y coords and dates are hard coded, so skipping a day requires some fussy work. This clearly calls for a Perl script to parse the HTML file and increment the Day of all unused entries (only), to be run when we take a skip day. In case the authors and editors are very naughty or lazy and skip more than 3 days -- and thus will be getting coal in their stocking -- the script can even remove the last box(es) to delete a day incrementing beyond 25th. =begin pre perl -i.bak mod6.pl index.html mv index.html.bak index.before.html diff -u index.before.html index.html | tee result-diff.txt ... -<br><div class="q"><a href="4/" style="left:425px; top: 5px">4</a></div> -<br><div class="q"><a href="" style="left:545px; top: 5px">5</a></div> -<br><div class="q"><a href="" style="left:665px; top: 5px">6</a></div> ... -<br><div class="C"><a href="" style="left: 5px; top: 52px">22</a></div> ... +<br /><div class="q"><a href="4/" style="left:425px; top: 5px">4</a></div> +<br /><div class="q"><a href="" style="left:545px; top: 5px">6</a></div> +<br /><div class="q"><a href="" style="left:665px; top: 5px">7</a></div> ... +<br /><div class="C"><a href="" style="left: 5px; top: 52px">23</a></div> =end pre The result is fairly subtle: The A as above is somewhat opaque. if you viewed this by opening the A<../|calendar page> door -- I -- you may have noticed B<5> missing; if not, you may need to compare closely to the previous A<../index.before.html|page state>, to see that the boxes from C<5..22> were incremented. (Yes Virginia, there will be a Christmas door for the 25th.) Since it's acting as XML, Twig does not normally respect original whitespace but the C 1> option assists us here. XML-Twig is allergic to some HTML that is NOT well-formed XML, so until we upgrade to XHTML, the script needs to insert end-slash in to empty tags as needed and the HTML-only Entities.N =sourcedcode mod6.pl =begin footnote nest This does mean that F<< <p> >> tags need close tags F<< </p> >>, and tags must be properly nested, B< not > straddled like F<< <b><i> blah </b></i> >>. =end footnote