Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 08 Aug 2000 16:12:33 -0400
From:      Nathan Vidican <webmaster@wmptl.com>
To:        questions@freebsd.org
Subject:   Windows ASCII files -> Unix ASCII Files
Message-ID:  <399069B1.1AB04AFF@wmptl.com>

next in thread | raw e-mail | index | archive | help
Is there any sort of utility to rip the ^M characters from the end of
each line in an ASCII text file as produced by Windows? I've tried using
a simple regexp with perl, as well as using chop/chomp, but niether seem
to work, any ideas?

Here is what I tried to create:

#!/usr/bin/perl

if (! @ARGV[1]) {
	$outfile = @ARGV[0];
} else {
	$outfile = @ARGV[1];
}
open(IN,@ARGV[0]);
@lines = <IN>;
close(IN);
open(OUT,">$outfile");
foreach $line (@lines) {
	chomp($line);
	print OUT "$line\n";
}

#end of script
As opposed to the above 'chomp($line)', I have also tried:
$line =~ tr/^M//;
chomp($line);
and before the for-loop, 'chop(@lines);'.
None of which have worked.

I figure there has got to be some easy way of doing this? Right now
we're FTP get/binary, then FTP put/ASCII 'ing in order to convert; which
needless to say is a pain in the neck.
	Any ideas or suggestions would be helpful.


-- 
Nathan Vidican
webmaster@wmptl.com
Windsor Match Plate & Tool Ltd.
http://www.wmptl.com/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?399069B1.1AB04AFF>