Perl300 has asked for the wisdom of the Perl Monks concerning the following question:
Hi all.
I am using this same approach from "Intermediate Perl" to check if an element of two dimensional array exist in a hash:
My problem is, the strings I'll have in @castaways and @list_1 are uppercase as well as lowercase. So as of now, the if condition fails if the string in @castaways is 'Hello' while in @list_1 it is 'hello'.my %hash = map { $_, 1 } @castaways; foreach my $person (@list_1) { if( $hash{$person} ) { print "$person is a castaway.\n"; #do something more } }
Is there any way to make the if condition do case insensitive match? I am trying to avoid making any change in the @castaways and @list_1 as they are taken from different sources and will be sent to other applications for processing. I don't know if changing case would mess things up for others.
UPDATE: Marked as solved in subject.
|
---|
Back to
Seekers of Perl Wisdom