Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: A little golfing challenge: Replacing letters with numbers (edited)

by rsFalse (Hermit)
on Feb 21, 2019 at 15:54 UTC ( #1230311=note: print w/replies, xml ) Need Help??


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'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1230311]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2020-12-06 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?