On Friday 13 December 2002 12:18, Gary Stainburn wrote:

This still doesn't answer his question.  He doesn't want to take up 20 Mb's 
of hdd space trying to do the edit. :)

btw, in a regex \r\n works fine. :)

- Jim

| On Friday 13 Dec 2002 10:42 am, christopher j bottaro wrote:
| > hey,
| > i wanna make a perl script that will convert those stupid "\r\n" dos
| > newlines to good unix "\n" newlines...=)  the problem isn't really a perl
| > problem, but a general programming problem that i've always kinda
| > wondered about.
| >
| > so i guess what i'm gunna do is open the file, read in a line, search for
| > "\r\n", if its there, replace it with just "\n", then write the new
| > (edited) line to a new file.  my problem is this...if the file is 10
| > megs, then not only is the program gunna read a 10 meg file, but write
| > one as well.  is there not a better way to do this?
| >
| > i can't really remove the "\r" in situ because as far as i understand, a
| > file is just an array of bytes and if i remove the "\r", i'd have to
| > shift everything else down one byte.
| >
| > thanks for the tips,
| > -- christopher
|
| The script below convers to/from DOS format depending on the name it's
| called by (I have unix2dos as a symlink to dos2unix).  It read STDIN and
| writes STDOUT.
|
| $ cat `which dos2unix`
| #!/usr/local/bin/perl -w
| while (<STDIN>) {
|   chomp;
|   if ( $0=~m/dos2unix$/ ) {
|     print "$_\n";
|   } else {
|     print "$_\r\n";
|   }
| }
| $

-- 

- Jim
- '94 MKIV TT auto
- '90 MKIII T manual

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to