{ local *FH; open(FH, "< ${file}.txt") or die "Can't open ${file}.txt: $!\n"; local *FH1; open(FH1, "> ${file}1.txt") or die "Can't create ${file}1.txt: $!\n"; while() { print FH1 $_; } }