Determine if a string starts with an upper-case character in Perl -


i need make subroutine in perl determines if string starts upper-case character. have far following:

sub checkcase {     if ($_[0] =~ /^[a-z]/) {         return 1;     }     else {         return 0;     } }  $result1 = $checkcase("hello"); $result2 = $checkcase("world"); 

that's correct. [a-z] might not match uppercase accented characters depending on locale. better use /^[[:upper:]]/.

also subroutine invocations shouldn't have $ character in front of them. i.e. should be:

$result1 = checkcase("hello"); $result2 = checkcase("world"); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -