use strict; use warnings; my $user_input = shift || die "I need input"; my $file = "file"; open FH, $file or die "can't open $file for reading $!"; my @arr = ; close FH; foreach(@arr){ s/VALUE/$user_input/g; } open FH, ">$file" or die "can't open $file for writing $!"; print FH @arr; close FH; rename $file, $file.time;