Just wanted to try this option out as well. So, I tried to use fc in the same example that choroba suggested and make it work. But it displays only "John" as a castaway.
#!/localperl/bin/perl use warnings; use strict; use feature 'fc'; my @castaways = qw( john Jane LUKE ); my @list_1 = qw( not John JANE luke ); my %hash = map { $_, 1 } @castaways; for my $person (@list_1) { if ( $hash{ fc($person) }) { # Tried with exists as well. Same res +ult. print "$person is a castaway\n"; } }
Result: John is a castaway
So I think in my case, using lc is the only option. BTW I am using (v5.24.0)
In reply to Re^3: Can we make hash key check in 'if' condition case insensitive?
by Perl300
in thread [SOLVED: Can we make hash key check in 'if' condition case insensitive?
by Perl300
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |