in reply to Matching the first letter in a string
If you're going to match a fixed number of letters in a fixed position (e.g., the first letter), use substr instead:
if (substr($title,0,1) eq $layer) { # do something... }
If you want the items checked regardless of case (that is, 'a' is treated the same as 'A'), force it to be lowercase:
if (lc(substr($title,0,1) eq lc($layer)) { # do something... }
As a side note, you're doing some extraneous quoting in there too, on the assignment to $title. I'd suggest changing that line to:
my $title = $dbrow{Title};
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Matching the first letter in a string
by tomhukins (Curate) on Jan 07, 2002 at 21:48 UTC |