|laziness, impatience, and hubris|
Getting abbreviations or initialsby Lady_Aleena (Deacon)
|on Aug 19, 2012 at 21:21 UTC||Need Help??|
This little script returns the abbreviation of a name. The only required option to use this is name. The script will die if name is not initialized.
This script will strip off articles at the beginning of the string input. "The Lord of the Rings" will return "LotR". If only one word is entered or left after the initial article in the string, the word will be returned. "Cher" will return "Cher"; "The Police" will return "The Police". Strings will be broken at spaces, underscores, hyphens, or a combination thereof. "Compact Disc read-only memory" will be returned as "CDrom", see the options below for how to return "CDROM".
There are three options that are not required.
If you want periods after each letter in the abbreviation, the option periods can be yes, true, or 1.
If you want all of the letters in the abbreviation to be capitalized, the option ALLCAPS can be yes, true, or 1.
If you want the output to be wrapped in the HTML tag, the option HTML can be yes, true, or 1. I added this because, as some here know, I use Perl to output a lot of HTML. :)
That will output:
I included an alternate subroutine called initials which is the same as abbr.
Now here is the code...
As always, I would love to know where I can clean this up.
Have a cookie and a very nice day!