my $Usage = "Usage: $0 infile outfile\n";
# open input and output files
die $Usage unless ( @ARGV == 2 );
open( IN, $ARGV[0] ) or die "Unable to read $ARGV[0]: $!\n$Usage";
open( OUT, ">$ARGV[1]" ) or die "Unable to write $ARGV[1]: $!\n$Usage";
...
####
converter.pl < some.input > some.output
# or
some_process | converter.pl | another_process
# or any combination of the above...
####
while () {
my @chars = split //;
for (@chars) { # $_ now holds one char per iteration
my $out = ( exists $name{$_} ) ? $name{$_} : $_;
print $out;
}
}