in reply to Need help converting!!!

  1. Use a shebang line at the top of your program, usually followed by strict and warnings.

  2. Use print to display text to the user.

  3. Use the diamond operator (readline) to read the input.

  4. Use if and comparison operators.

    1. A block starts with a {.

      1. Use + for addition.

      2. Use ++ to increment.

      3. Use == to test numeric equality.

        1. Use = for assignment.

      4. -

      5. > is an operator.

      6. < is an operator, too.

      7. Rather than using goto, wrap the whole part in a while loop.

    2. The while condition should test whether the loop should end or not. You'll have to adjust the algorithm a bit, as you can't test before you get the input, but the test is the first thing in the loop (or last, see do).

  5. / is the division operator .

  6. Use print again.

  7. Perl terminates once it has no more lines to execute.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Need help converting!!!
by tonto (Friar) on Nov 15, 2015 at 23:53 UTC

    4. >= is the "greater than or equal" comparison operator.

    Sorry choroba, I just had to...

Re^2: Need help converting!!!
by james28909 (Deacon) on Nov 16, 2015 at 02:18 UTC
    honestly, i dont really understand the whole "goto" thing or a legit reason to use it. in my mind though, it is a failure of the programmer to even understand their own logic, which makes them use such a shortcut, especially when there are plenty of other things you can do.
      "goto" is older.

      Many highlevel constructs are just gotos in disguise and their documentation still contains expressions like "go to beginning of loop"

      A language agnostic algorithm description might still say "go to" (like in this case)

      And because most use cases have been abstracted away doesn't mean there are no legit applications left for goto

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        well, i was just trying to understand it honestly, because in all the CRAZY shit i have had perl do , it has paid off, and i havent ever used "goto". but just because i have never used it, doesnt meant there isnt a reason to use it i reckon. im just a novice anyway, but i do appreciate the user-bility of perl. its like the "engrish" of the computing language :)

        Indeed - processors don't loop, they just jmp - which is extremely similar to the goto that is considered harmful. Fortunately, we have higher level constructs available. (Although even then, I'll often last out of a loop)

      Given that the OP was presenting a relatively-plain-English description of an algorithm, rather than actual code (or even pseudocode!), I'm rather confident that "goto 2" was intended to mean "repeat the above process, starting at step 2", not that he used or expected to use an actual goto statement.