foreach (@trt_files) # Each time round the loop, $_ # is set to an alias to one of the # elements of @trt_files. { $record = $_; # $record now contains the _value_ # of $_. It is _not_ an alias into # @trt_files. $record =~ s/date/$date/; # This changes $record # (it doesn't change $_ # or @trt_files). print "$_\n"; # Prints the (unchanged) value of $_ } #### foreach (@trt_files) { s/date/$date/; print "$_\n"; }