#!/usr/bin/perl # Fix the file names and product ID for February entries in the file: open (IN, "index.tab") || die "Could not open index for reading ($!)."; open (NEW, ">index.new") || die "Could not open new for writing ($!)."; while ($line=) { if ($line =~ /2005_feb([0-9]{2})/) { $day = $1; if ($line =~ /n[a-z]0([0-9]{3})\./) { $line =~ s/n[a-z]0([0-9]{3})(\.[a-z]{3}) /kp0502${day}_$1$2/g; $line =~ s/N[A-Z]0([0-9]{3})/KP0502${day}_$1/; $line =~ s/_2005_/_05_/; $line =~ s/_FIT//; } } printf NEW $line; } close IN; close NEW;