I actually wrote my first perl program last night. I read Learning Perl a couple weeks ago, but i didn't get around to actually writing anything until last night..

All the program does is take a text file and wrap square brackets around every single word in the file. In other words, it's an automatic hard link generator. It's smart enough to ignore all HTML tags and entities and anything that is already hardlinked. It also recognizes apostrophes as being part of the word. And it works. And its source code is completely unreadable.

Here it is, followed by its output when given a text file containing this writeup as an argument:


#!/usr/bin/perl
open(FHA, $ARGV[0]) or die "Input file unspecified or broken";
undef $/; $_ = <FHA>;
s/((?:(?:\<[^\>]*\>|\[[^\]]*\]|\&\w*\;)[^\w\<\[\&]*)*)([\'\w]+)/$1\[$2\]/g;
print $_;
I actually wrote my first perl program last night. I read Learning Perl a couple weeks ago, but i didn't get around to actually writing anything until last night..

All the program does is take a text file and wrap square brackets around every single word in the file. In other words, it's an automatic hard link generator. It's smart enough to ignore all HTML tags and entities and anything that is already hardlinked. It also recognizes apostrophes as being part of the word. And it works. And its source code is completely unreadable.

Here it is, followed by its output when given a text file containing this writeup as an argument: