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