#!/usr/bin/perl use strict; use warnings; use Date::Format; my $delete_temp = 0; # deleting the temp probably should be a command-line option my $old = 'filename.html'; my $tmp = $old . '.bak'; my $date = (time2str ("%Y-%m-%d", time)); print "\n\n$date\n\n"; rename $old, $tmp or die "Cannot rename $old to $tmp: $!\n"; open my $in, '<', $tmp or die "Cannot read $tmp: $!\n"; open my $out, '>', $old or die "Cannot write to $old: $!\n"; while ( <$in> ) { s!(\d\d\d\d-\d\d-\d\d)(-[a-z_]{5,30}\.zip)!$date$2!g; # no backslash before the sigil on $date print $out $_; } close $out or die "Error writing to $old: $!\n"; close $in; if ( $delete_temp ) { unlink $tmp or die "Error removing $tmp: $!\n"; }