acron5 has asked for the wisdom of the Perl Monks concerning the following question:

I need your assistance and suggestions..... I need to write a perl application that takes a text file that is FTP'd from one server to another server through an automated batch process and decrypt the contents and save as another text file. Decryption is a simple replace 1 with a , replace b with g etc. We have a table of values and what we are changing them to. Also I need this to not change a letter/number once it has already been changed. I hope that made sense. Any help would be greatly appreciated. Please keep in mind that I am fairly new to Perl.

Replies are listed 'Best First'.
Re: Encryption or Search and Replace?
by Albannach (Monsignor) on May 16, 2001 at 21:26 UTC
    For the "decryption" you will want tr. A couple of comments are in order:

    • If this is for your work, you should be aware that a simple substitution is an extremely easy code to break, so you are not providing much security at all by this mechanism.
    • If this is for a homework assignment, you will probably find the monks more helpful if you state that up front, and demonstrate some effort at solving the problem yourself.

    --
    I'd like to be able to assign to an luser

Re: Encryption or Search and Replace?
by Beatnik (Parson) on May 16, 2001 at 21:18 UTC
    check Net::FTP for the FTP stuff...

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: Encryption or Search and Replace?
by Sifmole (Chaplain) on May 16, 2001 at 21:29 UTC
    I don't think the question is actually about how to facilitate the transfer, but more about how to implement the "decoding".

    acron5, you should probably investigate the use of regular expressions (s/blah/foo/) or translation operator (tr/1-9/a-i/). The look at looping to see how one can iterate over the contents of an entire file. Then if you read closely about regular expressions and reading data from a file you will realize that you don't need to iterate and can do it all with one regular expression or translation.

      Thank you, I think this is the right direction.
Re: Encryption or Search and Replace?
by converter (Priest) on May 16, 2001 at 23:24 UTC
    Grab a copy of Convert::EBCDIC and look at the way it implements the ASCII to EBCDIC translation tables. That will probably give you a couple good ideas.