Hello,
Veltro,
Nice idea with 'ord'!
I've tried your code, and it outputs:
3 4 4 4 4 19 18 22 6 13 10 19 2 8 6 18 20 16 1 10 6 19 3 2 19 20 3 18
+18 1 0
Here the newline is absent, and one extra trailing space, these are not problems I think. But some extra characters at the ending does solution wrong. (
upd.:) Here I would suggest to modify printing line to one which converts undefined array elements to zero-length string, e.g.:
print( $ar[ord $_] =~ s/.\K$/ /r );
Which outputs (with extra space and without newline):
3 4 4 4 4 19 18 22 6 13 10 19 2 8 6 18 20 16 1 10 6 19 3 2 19 20 3 18
+18 1
upd.
...or back to '//' op (to avoid uninitialized value warnings):
print( ( $ar[ord $_] // '' ) =~ s/.\K$/ /r );