Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
- To: MLUG Members <EMAIL:PROTECTED>
- Subject: Re: [MLUG] simple perl one-liner question
- From: Mike Miller <EMAIL:PROTECTED>
- Date: Thu, 12 Apr 2007 21:29:58 -0500 (CDT)
- Delivery-date: Thu, 12 Apr 2007 21:30:26 -0500
- Envelope-to: EMAIL:PROTECTED
- In-reply-to: <EMAIL:PROTECTED>
- References: <EMAIL:PROTECTED> <EMAIL:PROTECTED> <EMAIL:PROTECTED> <EMAIL:PROTECTED> <EMAIL:PROTECTED> <EMAIL:PROTECTED>
- Reply-to: MLUG Members <EMAIL:PROTECTED>
- Sender: EMAIL:PROTECTED
On Thu, 12 Apr 2007, Mike Miller wrote:
I'm looking back at the old messages because I'm interested in finding a
simple way to convert letters A-Z to numbers 1-26. That has to be
really easy!
This seems to do it:
perl -pe 's/([A-Z])/ord($1)-64/eg'
I would also like to add a space before the number (that used to be a
letter), but if I insert a space, like so...
perl -pe 's/([A-Z])/ ord($1)-64/eg'
...it is ignored. I could do this but I'm sure it is unnecessarily long:
perl -pe 's/([A-Z])/ $1/g ; s/([A-Z])/ord($1)-64/eg'
That works but it is not pretty.
Mike
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members