#!/usr/bin/local/perl################################################################################################################################################################ To convert linbreaks in a text file to Macintosh format##			Version 1##	by Andrew Hardwick, http://duramecho.com, 2002/4/11##	Released under GNU Public Licence.################################################################################################################################################################# How To Use:## Run from a command line with the file name (path) as arguement.################################################################################################################################################################ Include librariesuse Cwd;		# To find current directoryuse strict;		# Disenable automatic variablesmy ($Text);my ($TextUnix,$TextMac,$TextDos);my ($CountUnix,$CountMac,$CountDos);# Get data from fileunless($ARGV[0])	{	die("Error: file name not specified to read.");}unless(open(FILE,'+<'.$ARGV[0]))	{	die("Error: Cannot open $ARGV[0] to read.");}binmode FILE;read FILE,$Text,-s $ARGV[0];# Convert linebreaks trying different possibilities & counting number found$CountUnix=(($TextUnix=$Text)=~s/\x0A/\x0D\x0D/g);$CountMac=(($TextMac=$Text)=~s/\x0D/\x0D/g);$CountDos=(($TextDos=$Text)=~s/\x0D\x0A/\x0D/g);# Check which file format it was inif(!$CountUnix&&!$CountMac&&!$CountDos){	die("Error: No linebreaks found.\n");}elsif($CountUnix&&!$CountMac&&!$CountDos){	print "Converted from Unix format.\n";	$Text=$TextUnix;}elsif($CountMac&&!$CountUnix&&!$CountDos){	die("It is already in Macintosh format.\n");}elsif($CountDos&&$CountUnix==$CountDos&&$CountMac==$CountDos){	print "Converted from MS-DOS format.\n";	$Text=$TextDos;}else{	die("Error: It appears to be in mixed format. It might not be text.\n");}# Write data to fileseek FILE,0,0;print FILE $Text;close FILE;###############################################################################
