in reply to Perl Cipher & questions on semantics/layout optimisation.

Pseudomander:

Actually, there are several bugs in your program. First, a simple test. Using the key 'ABCDEFG' and encrypt the string 'Now is the time for all good men to come'. Then decrypt the resulting string with the key 'ABCDEFG' -- that works just fine. Now let's demonstrate the bug: Try decrypting the result with key values 'XBCDEFG' or 'LMN'. It seems that the key you enter doesn't really do much.

If you add use strict and use warnings, then after prefixing some of the variables with 'my', you'll find a few errors to fix--You're not always indexing your arrays with variables! So adding strict and warnings would be my first suggestion.

When you get those errors out, you'll then see a page of warnings with your program output that should point you to the bug I noticed: You're not initializing @karray with your key string.

While your indenting looks pretty reasonable, I wouldn't double-space the code so much. It just makes everything longer and a bit harder to read.

...roboticus

When your only tool is a hammer, all problems look like your thumb.