in reply to A little golfing challenge: Replacing letters with numbers

The trick with golfing is to wait for Discipulus to have a good idea and steal it from him :P.

perl -nF -E '@h{split"",ARNDBCEQZGHILKMFPSTWYV}=1..22;say"@h{@F}"'
Only works on Linux because it needs double quote context (so you would need two extra chars on windows).

Edit: with the corresponding link

Edit 2: removed the -la options. I don't use -l with say, and -a is implied by -F

Edit 3: shorter than split:

perl -nF -E '@h{ARNDBCEQZGHILKMFPSTWYV=~/./g}=1..22;say"@h{@F}"'

Edit 4: -a is not implied by -F in perl v5.10 though

Replies are listed 'Best First'.
Re^2: A little golfing challenge: Replacing letters with numbers (edited)
by rsFalse (Chaplain) on Feb 21, 2019 at 15:54 UTC
    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'
      perl -pe 's/./ARNDBCEQZGHILKMFPSTWYV=~m!$&!&&"@+ "/ge'

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

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