[Sussex] Perl script.

John Crowhurst fyremoon at fyremoon.net
Sat Jan 11 23:40:01 UTC 2003


I'm trying to write a perl script that reads in a simple cypher and
encodes based on that cypher.

#!/usr/bin/perl
while( <> ){
   tr/a-z /%&)*$+|\\^><?~12:;_3456980#\-/;
   print "Encoded: $_";
   tr/%&)*$+|\\^><?~12:;_3456980#\-/a-z /;
   print "Decoded: $_";
}

This code above works, whereas:

#!/usr/bin/perl
open (T,"<cypher") or die "No Cypher";
while (<T>) {
 $cypher=$_;
}
close (T);
while (<>) {
 tr /a-z/$cypher/;
 print "Encoded: $_\n";
 tr /$cypher/a-z/;
 print "Decoded: $_\n";
}

Doesn't work, all it does is convert a-z into $cypher. Does anyone have
any ideas?

--
John






More information about the Sussex mailing list