in reply to Regexp substitution w/ variable value (again)

It's generally good form to include specific examples of what strings you want to transform and what you want the results to be (see How (Not) To Ask A Question). The documentation for how to use regular expressions can be found at perlre, with a tutorial at perlretut. While it is certainly possible to do this in a one-liner, given your stated experience level, you probably want to open the file (I/O Operators), make changes and then write the info out. And, as ikegami states, I think that \$ in your regex looks hinky.

You'll probably want something like:

#!/usr/bin/perl use strict; use warnings; use Date::Format; my ($input_file, $output_file) = @ARGV; my $date = time2str("%Y-%m-%d", time); #print "\n\n$date\n\n"; ## works open my $input, '<', $input_file or die "Open failure on $input_file: +$!"; my @contents = (); while (defined (my $line = <$input>)) { $line =~ s/(\d\d\d\d-\d\d-\d\d)(-[a-z_]{5,30}\.zip)/$date$2/; push @contents, $line; } close $input; open my $output, '>', $output_file or die "Open failure on $output_fil +e: $!"; foreach my $line (@contents) { print $output $line; } close $output;

This code could certainly be improved, but it should be sufficiently step-by-step to provide a good idea of how to proceed. The script as written should be called with

> perl script.pl infile outfile

The input and output file names can be the same for in-place edits.