On Thursday 25 April 2002 3:08 pm, Ron Powell wrote: > There is a utility out there that will convert unix-style end-of-lines (LF) > to dos-style (CR/LF)... > > Just for giggles, I'm trying to write a perl script to do this... > > Here's what I've tried... > > while (<INFILE>) { > $line = $_; > $line=~tr/\012/\015\012/; > print OUTFILE ("$line\n"); > } > > The problem is that the output, when viewed with notepad, contains > inappropriate line breaks... > > The same input file, when converted using the unix utility unix2dos, > converts "properly." This leads me to believe that I'm missing something > obvious here.... > > I'm not asking for the answer per se, but perhaps a pointer?
Here is *one* answer. Create the file and call it unix2dos. Then symlink it to dos2unix. __BEGIN__ #!/usr/local/bin/perl -w while (<STDIN>) { chomp; if ( $0=~m/dos2unix$/ ) { print "$_\n"; } else { print "$_\r\n"; } } __END__ > > ---------- > Ron Powell > Senior IT Analyst & > Network Administrator > gomembers, Inc. (Baltimore Office) > [EMAIL PROTECTED] > 410-494-1600 x4058 > <<...OLE_Obj...>> -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]