in reply to forgetting the simple stuff?

If you don't want to work with multiple files... can't you just store the data in an array while reading and substituting? Then after the work is done, reopen the file for writing out the array.
# read and subst my $fh = new FileHandle($file,"<"); my @data = (); while (my $line = <$fh>) { $line =~ s/$expr1/$expr2/; push(@data,$line); } close($fh); # write new data $fh = new FileHandle($file,">"); foreach my $line (@data) { print $fh $line; } close($fh);

print(map(lc(chr),split(6,qw/99672682673683684689632658645641610607/)));