#!/usr/bin/perl -w use strict; my $SCU= 'C:/Users/Desktop/a.txt'; open(FILE, "<$SCU") || die "File not found"; my @lines = ; close(FILE); #my $copy = $_; my @newlines; foreach(@lines) { push @newlines, s//xyz/rg for @lines; } open (FILE, ">", "$SCU") or die "Could not open file $SCU: $!"; print FILE @newlines; close(FILE);