If you ever decide to create your JavaScript to Perl converter, here are a couple of things I learned:

If you need to work with a long string, replacing characters, inserting strings, splitting/joining strings, then in JavaScript it is a lot faster to convert the string into an array of characters and then work on the array elements one by one. The split() and join() functions are extremely fast in JavaScript, however if this code is converted into Perl, it becomes very slow! I've noticed that Perl code runs faster if you leave the string as a string and work on it by replacing characters using the vec() and substr() functions. Perl is better with strings than arrays. Having a big array in Perl just slows things down. In JavaScript, it's just the opposite!

Secondly, the % operator works quite differently in Perl than in JavaScript! Consider the following JavaScript code:

C = A % B;

This translates to the following Perl code:

$C = $A - int($A / $B) * $B;

So, this operator is tricky! It's easy to overlook this difference.

In reply to Re: A comparison of Perl vs. JavaScript -- a reference table. by harangzsolt33
in thread A comparison of Perl vs. JavaScript -- a reference table. by taint

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