2010/6/26 Jenda Krynicky <je...@krynicky.cz>: > From: mrwawa <wade.w...@gmail.com> >> That is correct. I decided to just write the output to a separate >> file and then delete the original file. Thanks for all your help. >> >> Wade > > That's all you can do. If you just wanted to change a few characters > you could open the file for read&write (open my $IN, '<+', $file or > ...), but since you need to insert characters you have to create a > new file and copy the data, you can't expect the system to magicaly > shift the data after the row you amended.
Or this might work: $ cat foo A:BC:D $ perl -F: -i.bak -lane ' if ($#F == 2) { @foo=split(//,$F[1]) ; @F=($F[0], @foo, $F[2]) } ; print join(":", @F) ; ' foo $ tail -v -n +1 foo* ==> foo <== A:B:C:D ==> foo.bak <== A:BC:D Haven't tried it on a large file, so YMMV. Regards, - Robert -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/