[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-users] a compression problem!!!
- Subject: Re: [cobalt-users] a compression problem!!!
- From: "WebMost" <dbugger@xxxxxxxxxxx>
- Date: Tue Sep 12 13:19:05 2000
Ahoy Martin
1) There's a handy Debian utility named flip which converts DOS files to
nix, and vice-versa. Using alien, you could make it work with redHat.
2) I have also done this conversion just using Perl. Basically, you just
want to change the line returns from one type to the other. Here's what I
used:
#!/usr/bin/perl
$lf = '\012';
$cr = '\015';
$whichway = $ARGV[0];
$oldfile = $ARGV[1];
$newfile = $ARGV[2];
if($oldfile eq $newfile) {
die "old file and new files must have different names";
}
if($oldfile eq NULL) {
die "tell me which file to convert\n type \"flip [-w or -u] oldfile
newfile\"\n";
}
if($newfile eq NULL) {
die "tell me what file to output\n type \"flip [-w or -u] oldfile
newfile\"\n";
}
if($whichway eq "-u") {
$outtype = "Linux";
$end = "\n";
} elsif($whichway eq "-w") {
$outtype = "Windows";
$end = "\015\012";
} else {
die "Which way shall I convert this file?\n type \"flip [-w or -u]
oldfile newfile\"\n";
}
open (OUT,">>$newfile") || die "cannot write $newfile\n type \"flip [-w
or -u] oldfile newfile\"\n";
open(IN,"$oldfile") || die "cannot read $oldfile";
while($line = <IN>) {
$line =~ s/\n//;
$line =~ s/$lf//;
$line =~ s/$cr//;
$newline = '';
$newline = $line.$end;
print OUT "$newline";
}
close(IN);
close(OUT);
print "\n$oldfile converted to $outtype $newfile\n";
exit;
Aloha