Title: [Perl] hurr.pl Author: turkeli Pastebin link: http://pastebin.com/DZpSmTBH First Edit: Thursday 28th of June 2012 05:06:40 PM CDT Last Edit: Thursday 28th of June 2012 05:06:40 PM CDT use strict; use warnings; use feature qw(say); binmode(STDOUT, ":utf8");   #Check that we have exactly two parameters if ($#ARGV != 1) {    die "Please pass in a filename and a replacement string."; }   #Open source for reading and new file for writing my $file = $ARGV[0]; my $replacement = $ARGV[1]; open(my $handle, '<', $file) or die "Could not open file '$file' $!"; my $newfile = $file . ".fixed"; #Overwrite possible existing file by using > open(my $newhandle, '>', $newfile) or die "Could not open file '$newfile' for writing $!";   say "\nStarting search and replace in file '$file'.\n"; my $count = 0; my $startTime = time; my $content = ""; #Iterate through the rows in source while (my $row = <$handle>) {    #Remove row from the list    chomp $row;    my @matches;    #Match globally and push results into a two-dimensional array    push @matches, [$1, $2] while  ($row =~ /(.+?\.(?:jpg|png|gif))<\/a> \(/g);    my $match;    foreach $match (@matches) {       $count++;       say " * $count: " . @$match[0] . " -> " . @$match[1];       #Replace first match with second match globally       $row =~ s/@$match[0]/$replacement@$match[1]/g;    }    $content .= $row . "\n"; } #Echo content to new file print $newhandle $content;   my $elapsedTime = time - $startTime; say "\nReplaced $count occurences in about $elapsedTime seconds. Fixed source should be in '$newfile'.\n";