Categories
Software and Programming

IO::All to rule them all

I just wrote my first perl script using IO::All. I think I have to sit down and breath.
The job? change every link in a directory tree of HTML files to use the name of the new server instead of the old one.
The script:


#!/usr/bin/perl
use IO::All;
my ($datadir) = shift;
for my $file (io($datadir)->All) {
	my $text < $file;
	$text =~ s|fred[^\:]*?\:1337|bert|g;
	$text > $file;
}

(The regular expression made use of the fact that the original server, call it fred, was running a web server on a non-standard port, say 1337).

This. Is. Very. Cool.