delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/02/06/19:26:22

From: emmess AT bml DOT se DOT org (Martin Svenningsson)
Subject: Re: \n->\r\n?
6 Feb 1998 19:26:22 -0800 :
Message-ID: <3.0.5.32.19980206232620.00a297e0.cygnus.gnu-win32@triton.tripnet.se>
References: <3 DOT 0 DOT 5 DOT 32 DOT 19980206171424 DOT 00952600 AT triton DOT tripnet DOT se>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

-----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 AT bml DOT se DOT 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 AT bml DOT se DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019