in reply to Search and Replace

Should you need to the non-oneliner solution, you might want to try the following:

open (INFILE, "<myfile.txt"); open (OUTFILE, "<myfile.txt"); while (my $row = <INFILE>) { $row =~ s/~/\r/g; print OUTFILE $row; } close (INFILE); close (OUTFILE);

Michele.

Replies are listed 'Best First'.
Re: Re: Search and Replace
by mikevanhoff (Acolyte) on Jun 09, 2003 at 17:43 UTC
    Thank you for help. That did the trick. However, I seem to have found a problem. Since the results file will be used to load a database the "^M" cannot appear in the file. instead of getting: "this that the-other-thing^MHere is the other thing^M" I need to get: "this that the-other-thing" "Here is the other thing" Can you help with this? Thanks in advance
      These two solutions are replacing tildes with carriage return characters (\r or \x0D). If you want line endings, then you should replace tildes with \n like someone else showed. That will turn into the line ending characters for your platform (CRLF, LF).