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

How can I do a pattern match for a group of letters to be contained anywhere within a word.....irrespective of case sensitivity. Por ejemplo...
if ($line =~ /abcd/) {
I need to pull this pattern if it's found in either case.. One Luv

Replies are listed 'Best First'.
Re: Conditions and Case Sensitivity
by Zaxo (Archbishop) on Oct 14, 2003 at 15:44 UTC

    You're almost there. The /i flag gives you case insensitivity: if ($line =~ /abcd/i) {

    After Compline,
    Zaxo

Re: Conditions and Case Sensitivity
by pg (Canon) on Oct 14, 2003 at 16:23 UTC
    If the question actually means "to match any character within a group of characters", not "a sequence of characters" (it at least sounds not very clear to me), then you may want to use [], see the following example:
    my $line = "abd"; if ($line =~ /abcd/i) { print "matched the first case\n"; } if ($line =~ /[abcd]/i) { print "matched the second case\n"; }