Simple Encryption Script

T

Tad McClellan

Nikos said:


Yes you do.

But how is this helpfull?


It seperates (sic) the values of the @array when it comes to
print "@array".

I cant think of a reason other that seperate the values of the @array
when it comes to print "@array";


See? You see.

:)

Perl is chock-a-block full of features that make most programming
easier, $" is but one of them.
 
R

RedGrittyBrick

Nikos said:
Joe said:
Nikos said:
$toBeEncrypted =~ tr/a-zA-Z/b-zA-Za/;



a-z transletes to b-z
A-Z msut to B-Z why you say A-Za ?



If you use tr/A-Z/B-Z/ then Y translates to Z, but the character
that Z translates to is not specified. So either
tr/A-Z/B-ZA/
or
tr/A-Z/B-Z[/
is appropriate.

Your program should explicitly document what it does to
characters that are outside of the A-Z range.


Yes, now i think i understand. So the 'A' in tr/A-Z/B-ZA/ means that
every other character outside the A-Z range should be changes to A

No, lets make it clearer, in tr/A-Z/B-ZA/
1) The "A-Z" is shorthand for "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2) The "B-Z" is shorthand for "BCDEFGHIJKLMNOPQRSTUVWXYZ"
3) The final "A" just stands for "A"
4) From 2 and 3 we get "BCDEFGHIJKLMNOPQRSTUVWXYZA"
5) Each letter in the first string gets tranlated to the corresponding
position in the second string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
to "BCDEFGHIJKLMNOPQRSTUVWXYZA"

So, for example "P" in the first string is translated to "Q" in the
second string.

AFAIK the order is unimportant[1] so it is exactly equivalent to
tr/QWERTYUIOPASDFGHJKLZXCVBNM/RXFSUVJPQBTEGHIKMAYDWCMO/
but that would be a pointlessly obscure way to write it.

Any character not matched in the first string is not altered in the result.

[1] so long as the strings are equal in length, and probably subject to
some other edge conditions I don't know about.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,460
Latest member
eibafima

Latest Threads

Top