This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: \n->\r\n?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Svenningsson writes: (17:14 1998-02-06 -0100)
 > Can I do something simular to transalte from lf to crlf?

OK, first of all; sorry for replying to my own mail..

I needed to translate a couple of files quick so I wrote this little
perlscript that I wish to share with everybody. (but I still don't
know if there's a easier way to do it)

PS Im not a perl programmer, so don't laugh at me ;P DS

- ---- lf3crlf.pl start ----
#!/bin/perl
##
# lf2crlf.pl - translates unix lf files do dos crlf.
# By: EmmEss <emmess@bml.se.org> Feb 1998.
# Do whatcha want, NO WARRANTY :).
####

if ((!@ARGV) or ($ARGV[0] eq '-h') or ($ARGV[0] eq '--help')) {
  print "\nlf2crlf.pl by EmmEss - translates \\n to \\r\\n\n";
  print "Usage: lf2crlf lf_file > crlf_file\n";
  exit(0);
}

if (open(INFILE, $ARGV[0])) {
  @lffile = <INFILE>;
  close(INFILE);
} else { 
  print "Can't open $ARGV[0]\n"; 
  exit(-1);
}

foreach $i (0..$#lffile) {
  $lffile[$i] =~ s/\n/\r\n/g;
  print $lffile[$i];
}
- ---- lf3crlf.pl end ----

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/AwUBNNup2Ll80C/nFO0qEQLk9ACfXUFUrDNnOssTr8YJUwx3uhnOxBwAoPpD
dlqNYd856oEXcwcGhZGU9G6M
=l1cO
-----END PGP SIGNATURE-----


__________________________________________________
Martin 'EmmEss' Svenningsson - Helsingborg, SWEDEN
http://www.tripnet.se/~emmess/ - emmess@bml.se.org
See my mail headers for info about my PGP pub keys 
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]