Cover V06, I03
Article
Figure 1
Listing 1
Listing 2
Table 1
Table 2
Table 3
Table 4

mar97.tar


Listing 1: Change DOS or Mac text format to UNIX

#!/opt/local/bin/perl

$, = ' ';               # set output field separator
$\ = "\n";              # set output record separator

open (infile,$ARGV[0]);

# Check to determine the file format and set the appropriate $Endline.

# The line must be less than 500 characters long
read(infile,$testfile,500);
$cr = index($testfile,"\r");
$nl = index($testfile,"\n");

# Mac formatted PPD
if ( $cr > 0 && $nl == -1 ) {
$Endline = "\r";
}
# DOS formatted PPD
if ( ($nl - $cr) == 1 ) {
$isDOS = 1;
$Endline = "\r\n";
}
# Why convert UNIX to UNIX, but just in case...
if ( $cr == -1 && $nl > 0 ) {
$Endline = "\n";
}

$/ = $Endline;

# Resets the file to the begining
seek(infile,0,0);

line: while (<infile>) {
chop;
if ( $isDOS == 1 ) {
chop;
}
print;
}

# End of File