Main Content

Pure Perl

Archive - Originally posted on "The Horse's Mouth" - 2007-08-03 07:45:37 - Graham Ellis

#!/usr/bin/perl -n
s/\<.*?>//g;
@fol = split;
if (/06:44/) {
  @op = @fol[1..$#fol -1];
  print "@op\n";
  }


I still enjoy - REALLY enjoy - filtering data and grabbing stats out of it. And what better than Perl - the Practical Extraction and Reporting Language. See example above.

* Read in a file line by line
* Delete out all HTML tags
* Find all references to the 06:44 train
* Output certain data about the running of the train from each reference

And that formed the basis of a charming little report shown here.

Want to learn Perl? We have a Perl Course running from 20th August 2007 ... and it's repeated every couple of months if you come to this thread in September or October.