Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I couldn't follow the logic of your JS code, so I ran it as is on my machine. Here's the output:
It seems that the aim is to increase the numeric (ascii+) value of each character in the string by 1, then add a zero on the end. Testing with a number of other random strings appears to confirm this analysis. So here's how I'd translate the code into Perl:
Update: Further testing reveals that your code also, for some reason, strips all digits except zero from the string. Easy peasy: say join '', ( map { chr ord( $_ ) + 1 } grep /[^1-9]/, split //, $str ), 0;In reply to Re: Javascript to Perl = fail
by Not_a_Number
|
|