malaga has asked for the wisdom of the Perl Monks concerning the following question:

I need to make this comparison case insensitive. Can I do it anywhere within this statement? Thanks.
foreach $ref ( @products ) { if ($ref->{prodname} =~ ($value)) {

Replies are listed 'Best First'.
(MeowChow) Re: case insensitive: Which tree to bark up?
by MeowChow (Vicar) on May 27, 2002 at 02:59 UTC
    if (lc($ref->{prodname}) eq lc($value)) ...

    unless you actually need to do a partial match, for which case:

    if ($ref->{prodname} =~ /\Q$value/i) ...

       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
Re: case insensitive: Which tree to bark up?
by malaga (Pilgrim) on May 27, 2002 at 07:36 UTC
    Thank you. What about on the hash side? How can I make that case insensitive?
Re: case insensitive: Which tree to bark up?
by malaga (Pilgrim) on May 27, 2002 at 09:43 UTC
    Thank you, I'll check it out.