Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Caesar Cipher

by marinersk (Chaplain)
on Aug 05, 2013 at 15:58 UTC ( #1047926=note: print w/ replies, xml ) Need Help??


in reply to Caesar Cipher

The tr approach is probably the most Perl-True approach for a one-off script to perform the cipher with a given (i.e., hard coded) shift.

However, since this smells like like a homework assignment, and you are new to Perl, I would be inclined to suggest something a little more generic -- use an array.

It would be slower, but since you would be building the underlying mechanisms, you would understand its workings more thoroughly.

I know you are essentially asking for theoretical guidance, but have you done any work on this so far? Like, for example, the code which collects the text to be so ciphered?

For example -- intentionally silly:

#!/usr/bin/perl use strict; { foreach my $inputString (@inputArray) { my $cipheredText = &ceaser_cipher($inputString); print "'$inputString' becomes '$cipheredText'\n"; } } exit; sub cipheredText { my ($rawText, @otherParameters) = @_; # The magic happens here -- have entered a SoPW request at PerlMo +nks. } __END__


Comment on Re: Caesar Cipher
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047926]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-08-30 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls