if ALL CAPITAL LETTER.....

What would be best to convert the following names (just those with ALL CAPITAL LETTERS)
LONGNAME to Longname
LONG NAME to Long Name
NAME (no conversion)
Long Name (no conversion)


if((length($NAME) > 6) && ALL CAPITAL LETTER???) {
Karina051699Asked:
Who is Participating?
 
Kim RyanConnect With a Mentor IT ConsultantCommented:
This should convert what you want, but preserve
strings like 'Long Name'

if( length($NAME) > 6)
{
   # In each word, uppercase 1st letter, lower case rest  
   $NAME=~ s/(\w+)/\u\L$1/g;
}
0
 
Karina051699Author Commented:
Thanks,

Thats the first part of the solution. But how to dtermine the input is lower or uppercase?
if the user wants his name all lower case, it should not change it. Just, if the name
is longer than 6 and all capitals it should convert it with your provided code.
(space problems in a little frame)
0
 
Kim RyanIT ConsultantCommented:
OK, I think I understand now. Try

# $NAME more than 6 chars, all capitals
if( length($NAME) > 6 and $NAME =~ /[A-Z/ ) {...}




0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
Karina051699Author Commented:
That's it!

Thanks, teraplane
0
 
ozoCommented:
length($NAME) > 6 and $NAME !~ /[a-z]/
0
 
Karina051699Author Commented:
I used ozo's line because it wont convert correct names like

My Name

or Myname

(just ALL CAPITALS like MY NAME or MYNAME ...)

Thanks Ozo
0
All Courses

From novice to tech pro — start learning today.