$line =~ s/Kept/Resold/g; # This replace works fine $line =~ s/,-1,/,$rt,/g; # Variable $rt = 275805