Path: utzoo!news-server.csri.toronto.edu!torsqnt!hybrid!scifi!bywater!arnor!arnor!victor From: victor@arnor.UUCP (Victor Miller) Newsgroups: comp.lang.perl Subject: Can this be done more slickly Message-ID: Date: 15 Mar 91 22:17:26 GMT Sender: news@arnor.uucp (NNTP News Poster) Reply-To: victor@ibm.com Distribution: comp Organization: IBM, T.J. Watson Research Center Lines: 23 I wrote the function given below to transform a string with -'s in it so that all alphabetics were lower case, except at the beginning of the string or immediately after a dash, in which case it would be upper case. The follow works correctly, but I was wondering (in the JAPH spirit), if there is a more clever (or concise) way of doing it. sub normalize { local(@pieces) = split(/-/,$_[0]); local($i); foreach $i (0..$#pieces) { $pieces[$i] =~ tr/A-Z/a-z/; substr($pieces[$i],0,1) =~ tr/a-z/A-Z/; } join('-',@pieces); } -- Victor S. Miller Vnet and Bitnet: VICTOR at WATSON Internet: victor@ibm.com IBM, TJ Watson Research Center