On 1 November 2001 22:17, shalini Raghavan [mailto:[EMAIL PROTECTED]] wrote: > Thank you for the help.I've been trying to use a script that uses the > map function in the following manner > my $var = chr(13); for the control character ^M > my @mapped = map{ > s/$var//g; > s/"//g; > $_; > }@contents;
Why not use s:\cM::g for the first subtitution (which will save it being compiled on each usage -- Perl assumes that $var will be changing). The \cX is a way of writing control-X. However you might also want to consider using the end of line escape \n. > What I'd really like to do though is to be able to write back(append) > to the same file.I am confused about opening a file in the > append mode. Have a look at in-place editing with the -i command line option in perldoc perlrun (Essentially, Perl sets up stdin to be from the old version of the file, and stdout to be to the new version.) So with this, call as perl -i myScript.pl DataFileName where myScript.pl is (untested) #!perl -w use strict; while (<>) { s/\cM|"//g; print; } However, you've also got the -p command line option that puts the look and print in for you, so you can do something like: perl -i -pe "s:\cM|\"::g" DataFileName (command interpreter/shell quoting may need some adjustment). Hope this helps. Richard Cox Senior Software Developer Dell Technology Online All opinions and statements mine and do not in any way (unless expressly stated) imply anything at all on behalf of my employer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]