tie @lines, 'Tie::File', $file or die "No file found to work with."; $lines[0] = 'foo'; # this should change the tied file