in reply to Take file A , translate it, place in new file
#!/usr/bin/perl my $Usage = "$0 input_file.name output_file.name\n"; ( @ARGV == 2 and -f $ARGV[0] ) or die $Usage; open( IN, "<", $ARGV[0] ) or die "$ARGV[0]: $!"; open( OUT, ">", $ARGV[1] ) or die "$ARGV[1]: $!"; while (<IN>) { tr/a-zA-Z/A-Za-z/; # invert case, just for fun print OUT; }
#!/usr/bin/perl my $Usage = "Usage: $0 [<] input.file > output.file\n"; die $Usage if (( @ARGV > 0 ) ^ ( -t STDIN )); while (<>) { tr/a-zA-Z/A-Za-z/; # invert case, just for fun print; }
As for your usage of "tr///", I wonder what you're trying to accomplish with tr/a-zA-Z/0-310/ because that really means:
When I see a dash used between two numerics like that with the tr/// operator, my first impression is that the intent is probably different from the actual result...a -> 0 \ b -> 1 \ "0-3" defines a continuous character range c -> 2 / starting at "0", ending at "3", incl. "1" & "2" d -> 3 / e -> 1 fg-zA-Z -> 0
|
|---|