Hello all, this is my first post here and in relation to my first Perl script. I've encountered no bugs however most recently having learnt python my presentation /methods aren't very perl reflective. I was wondering if people could give some pointers on: A. The generally accepted presentation. B. Any ways I could have coded this more effectively/effeciently.

##Authored by Troy Osborne (Pseudomander) 4:45am 25/02/2012 EST +10## ##Free to redistribute, use, copy, upload & adapt this work, all I ask + is if it in anyway represents the original version please give credi +t where due## $key=""; @karray= split(//,$key); $offsetpattern=""; $offsetpattern2=""; while (length($key) < 4) { print "Please Enter Your Desired Key (5 or more characters) \n --> + :"; $key=<>; } for ($i=0;$i<length($key);$i++) { $temp =0; for ($i2=0;$i2<length($key);$i2++) { $temp += (ord(@karray[i])+ord(@karray[i2])); $offsetpattern .= chr((ord(@karray[i])+ord(@karray[i2])+ o +rd($offset2[$i % length($key)]))%256); } $offsetpattern2.=chr(int($temp /length($key))%256); } @offset = split(//,$offsetpattern); @offset2 = split(//,$offsetpattern2); print "Encrypt or Decrypt (E/D)\n --> :"; $inp=<>; if (($inp=~/E/) or ($inp=~/e/)) #Encryption { print "Enter Plaintext\n --> :"; $plaintext = <>; $len = length($plaintext)-1; @array = split(//, $plaintext); for ($i=0;$i<$len;$i++) { $char = chr((ord(@array[$i]) - ord($offset[$i % length($key)*l +ength($key)])+ ord($offset2[$i % length($key)]))%256); print chr(ord($char)-($i%6)); } } elsif (($inp=~/D/) or ($inp=~/d/)) #Decryption { $a=""; print "Enter Cyphertext\n --> :"; $cyphertext = <>; $len = length($cyphertext)-1; @array = split(//, $cyphertext); for ($i=0;$i<$len;$i++) { $char = chr((ord(@array[$i]) + ord($offset[$i % length($key)*l +ength($key)]) - ord($offset2[$i % length($key)]))%256); print chr(ord($char)+($i%6)); } } $wait =<>;

In reply to Perl Cipher & questions on semantics/layout optimisation. by Pseudomander

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.