http://www.perlmonks.org?node_id=1230311


in reply to Re: A little golfing challenge: Replacing letters with numbers (edited)
in thread A little golfing challenge: Replacing letters with numbers

One longer variant, also with extra spaces, but with less than two of them on each line:
perl -pe 'ARNDBCEQZGHILKMFPSTWYV=~/$_(?{print pos.$"})/ for/./g,$_=$/'
Corresponding link. (upd. corrected a link)

And with similar idea but a bit shorter:
perl -pe 's/./ARNDBCEQZGHILKMFPSTWYV=~m!$&!&&"@+ "/ge'

Replies are listed 'Best First'.
Re^3: A little golfing challenge: Replacing letters with numbers (edited)
by Eily (Monsignor) on Feb 22, 2019 at 11:06 UTC
    perl -pe 's/./ARNDBCEQZGHILKMFPSTWYV=~m!$&!&&"@+ "/ge'

    Really nice! Well done! Going just a little further:

    perl -pe 's/./ARNDBCEQZGHILKMFPSTWYV=~$& &&"@+ "/ge'