Programming by committee!  This is kind of fun, in a twisted way.  OK,
incorporating John's and Wade's suggestions:


#!/usr/bin/perl -w

use strict;
use File::Basename;

my $dos        = "\015\012";
my $mac        = "\015";
my $unix       = "\012";
my $myPlatform = "$unix";
my $iam        = basename($0);
my $regexp     = "";

$myPlatform = $mac if $^O =~ /mac/i;
$myPlatform = $dos if $^O =~ /win|dos/i;

my %subs = (
  crlf     => sub { s/[\015\012]+/$myPlatform/o },
  dos2unix => sub { s/$dos/$unix/o },
  unix2dos => sub { s/$unix/$dos/o },
  mac2dos  => sub { s/$mac/$dos/o  },
  mac2unix => sub { s/$mac/$unix/o },
  dos2mac  => sub { s/$dos/$mac/o  },
  unix2mac => sub { s/$unix/$mac/o },
);

die "I do not recognize my own name."
  unless exists ($subs{$iam});

my $sub = $subs{$iam};
while(<STDIN>) {
  &$sub;
  print;
}


-- 
William R Ward            [EMAIL PROTECTED]          http://www.wards.net/~bill/
-----------------------------------------------------------------------------
     If you're not part of the solution, you're part of the precipitate.

Reply via email to