TobyInkster.co.uk

Articles Tagged with “Perl”

29/03/2008: Cognition 0.1 Alpha 6

Tonight I’ve released another alpha version of Cognition, my semantic web parser. Changelog includes:

  • Microformats:
    • Add option (disabled by default) to require <head profile> for microformat support. Microformat profiles are treated as opaque strings! Supports the following profiles:
      • http://purl.org/uF/2008/03/
      • http://www.w3.org/2006/03/hcard or http://purl.org/uF/hCard/1.0/
      • http://dannyayers.com/microformats/hcalendar-profile or http://purl.org/uF/hCalendar/1.0/
      • http://purl.org/uF/hAtom/0.1/
      • http://purl.org/uF/rel-tag/1.0/
      • http://purl.org/uF/rel-license/1.0/
      • No profiles required for rel-enclosure, adr or geo (yet).
    • Support for hAtom, WebSlices.
      • In addition to hAtom 0.1, rel-enclosure is supported within hEntries.
    • Improve include-pattern support to prevent some infinite loops.
  • GRDDL:
    • Add option (disabled by default) to require for GRDDL.
    • Add option to check profile URLs for…

05/02/2008: Looking Ahead to Perl 6

One of the most important changes in Perl 6 over earlier versions is that it has started out as a written specification, which may end up with several different implementations. In previous versions of Perl, alternative versions had to implement all the quirks of the official Perl interpreter, as the definition of the Perl language was “whatever the Perl interpreter will interpret”, which was (of course) a moving target, as each released version introduced new features and changed existing behaviour (though usually only on the peripheries of the language). The lack of a stable written specification killed off many useful projects, such as the Perl compiler (perlcc).

The written specification is what allows me to write this article right now, as the current implementations of Perl 6 are only partial — indeed, the specification is not yet complete, but I can comment on those parts that have been written. There are way too many changes to touch on them all, but I’ll try to write about some of the most…

22/01/2008: CSS to HTML Compiler

I’ve searched around the ‘Net for something like this before, but without success, so decided to write my own. The basic idea is this: there are certain circumstances in which you need to write some styled HTML without access to the document’s header. For example, when composing HTML-formatted e-mails, which may be displayed in a web-based e-mail client; when adding content to limited content-management system; or in an eBay auction description. In such a situation, you can’t (validly) include a <link rel="stylesheet"> element, nor a block (if you do include such a construct it may just about work, but the document will not be valid), so instead you are reduced to using HTML style attributes all over the place.

However, it is slow work using style attributes as you can’t take advantage of CSS selectors. Instead…

06/01/2008: dhyana.pl/0.3

Here’s my latest update to dhyana.pl

Change Log

  • Added a title to the output image, which can be in a different font and colour from the rest of the text.
  • Use Getopt to parse command line, and accept more options.
  • Improved handling of certain dodgy WMV files, mostly thanks to Matt Pinkham.
  • Improved use of FFMPEG
  • Code straightened out to use functions — it used to be one big long mess.
  • Added a help function — just run the program with the —help paramater.

Requirements

  • Perl Getopt::ArgvFile
  • Perl Getopt::Long ≥ 2.33
  • Perl Pod::Usage;
  • mplayer
  • ImageMagick

Optional

  • Perl File::chdir
  • Perl File::Spec
  • Perl Cwd
  • FFMPEG

All of the Perl modules can be found in CPAN, here is the FFMPEG site and here is mplayer. And don’t forget ImageMagick.

Download

18/11/2007: Dhyana.pl Updated

This release works around errors in capturing screen shots from certain WMV files. It also changes the default geometry from 240×180+0+0 to “auto” which is an automatically calculated, hopefully appropriate, geometry.

19/08/2007: Sequential Video Thumbnails on Linux

So, I was looking for a way to create sequential video thumbnails (like this one) from a video file on Linux. I found that my options were severely limited. On Windows there are a plethora of tools capable of this fairly simple task, including Media Player Classic, but on Linux all I could find was QFrameCatcher. The QFrameCatcher website was inaccessible yesterday; today I managed to download the source code, but couldn’t get it to build.

Anyway, I decided it probably wouldn’t be very difficult to build my own so…

dhyana.pl

dhyana.pl is a small Perl script that co-ordinates mplayer and ImageMagick to create a lovely montage of thumbnails. (Dyhana — roughly pronounced as “jahna” — is the Sanskrit word for a deep meditation.)

17/07/2007: PHP vs Perl

Here’s a simple program which calculates, to eight decimal places, the value of the Golden Ratio φ implemented in both PHP and Perl, to demonstrate their similarities…

18/06/2007: dict, thes & ency

dict is a command that is supplied with most Linux and BSD distributions. If you enter dict foo at the command-line, you get back the dictionary definition of “foo”. Normally several different dictionaries are supplied, including some dictionaries of translation, and it’s possible to look up the word on various online dictionaries too.

As counterparts to dict I’ve created thes for looking stuff up in Moby’s Thesaurus and ency for online encyclopaedia Wikipedia

16/04/2007: Create Your Own Dan Brown Novel

I put this together back in January 2006, but never mentioned it on my website — I just posted it on a couple of newsgroups. It’s pretty good fun and rather realistic.

Create your own Dan Brown novel

html2highlight

Summary not available.

source2html

I needed to print out a directory full of small scripts. This Perl script will go through the current directory and create a pretty HTML page of all the files in that directory. That HTML page can then be fed to a browser for printing.

#!/usr/bin/perl

$cd = `pwd`; chomp $cd;
$ls = `ls -1 $cd`;
@ls = split(/\n/,$ls);

print "<title>Directory Listing $cd</title>\n";
print "<h1>Directory Listing $cd</h1>\n";

$ll = `ls -l '$cd'`;
chomp $ll;
print "<pre style='padding:1em'><b>$ll</b></pre>\n\n";

foreach $f (@ls) {

  if (!(-d $f)) {

    $l = `ls -l '$f'`; chomp $l;
    print "<div style='border:2px solid black;padding:1em;'>\n";
    print "<h2 style='margin:0;padding:0;'>$f</h2>\n";
    print "<pre><b>$l</b></pre>\n";
    print "</div>\n";

    $t = `cat '$f'`;
    $t =~ s/&/&amp;/g;
    $t =~ s/</&lt;/g;
    $t =~ s/>/&gt;/g;

    print "<pre style='padding:1em'>$t</pre>\n\n";

  }

}

This software is distributed under the terms of the GNU GPL.

Password Scripts

Summary not available.

jukebox.pl

jukebox.pl is a GTK2 player for Ogg Vorbis files written in Perl. It uses SDL for audio output.

Why yet another Linux media player?
Because this one has just the features I need and nothing more. It provides the facility to select which song you want to hear next (and if no songs are queued, will select one at random); skip the current song; pause; and a volume control. I don't need anything other than that, and I'd image that a lot of other people don't either. (If anything, the volume control is an extravagance!)

steg-encode.pl

Summary not available.

Google Search

Blogroll

Here are some other sites. Some might be good; some might be rubbish. You decide.