The original question concerned the first letter of $title, whereas your answer compares the first character.
To match the first letter case insensitively, try:
NB. I'm using [a-z] rather than \w because \w includes the underscore character, which isn't a letter.my $title="$dbrow{'Title'}"; $title =~ m/([a-z])/i; # Match the first letter in $title if (lc($1) eq lc($layer)) { #do something... }
Given that you seem to be working with results returned from a database, it's almost certainly better to check the first letter matches in the SQL query, rather than in the Perl code later on. Try something like SELECT * FROM table WHERE field LIKE "A%" to match records where field starts with the letter A.
In reply to Re: Re: Matching the first letter in a string
by tomhukins
in thread Matching the first letter in a string
by Kiko
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |