February 2006
Intermediate to advanced
304 pages
6h 16m
English
Because different operating systems use different EOL conventions, when moving text files from one system to another, you must perform an EOL conversion. This script shows you one way of doing this.
1 use strict; 2 use warnings; 3 4 sub usage() 5 { 6 print STDERR "Usage $0 <unix|linux|dos|mac|apple>\n"; 7 exit(8); 8 } 9 10 binmode(STDIN); 11 binmode(STDOUT); 12 13 my $eol = "\n"; 14 15 if ($#ARGV != 0) { 16 usage(); 17 } 18 if ($ARGV[0] eq "linux") { 19 $eol = "\n"; 20 } elsif ($ARGV[0] eq "unix") { 21 $eol = "\n"; 22 } elsif ($ARGV[0] eq "dos") { 23 $eol = "\r\n"; 24 } elsif ($ARGV[0] eq "apple") { 25 $eol = "\r"; 26 } elsif ($ARGV[0] eq "mac") { 27 $eol = "\r"; 28 } else { 29 usage(); 30 } 31 32 while (1) { 33 ...Read now
Unlock full access