#!/usr/bin/perl -s # Convert DOS's text files into Mac's text files or vice versa # perl -s dos2mac.pl -s=dos -t=mac InDir OutDir if (@ARGV < 2) { print <($TgtEnc) $outfile\n"; # &Read_Convert_Write($infile, $outfile); system("perl -p -e '$substitute' < \"$infile\" > \"$outfile\""); $NumFiles++; } } sub Read_Convert_Write { my($infile, $outfile) = @_; open(INPUT, "< :raw", $infile) || die "Can't open < '$infile' for reading: $!"; open(OUTPUT, "> :raw", $outfile) || die "Can't open > '$outfile' for writing: $!"; while () { # from_to($_, $SrcEnc, $TgtEnc); # switch encoding print OUTPUT; # emit raw (but properly encoded) data } close(INPUT) || die "can't close '$infile': $!"; close(OUTPUT) || die "can't close '$outfile': $!"; } sub CreateDir { my($OutDir) = @_; my(@Path, $path, $i); @Path = split /[\/\\]/, $OutDir; for($i=0; $i<@Path; $i++) { next if $Path[$i] eq ''; $path = join('/', @Path[0..$i]); if (not -d $path) { print STDERR "Creating the folder:'$path'\n"; #, \$OutDir='$OutDir'\n\@Path='@Path'\n"; mkdir($path, 0755) or die "Cannot mkdir: '$path', $!"; } } }