$_ = "KL5-8590"; # for now, we'll match against the default $_ variable if (/KL5-[0-9]{4}/) { print "I think this is a fake number\n"; } elsif (m) { print "Is there an airline involved?\n"; } # ----- if (/kl5-[0-9]{4}/i) { print "I think this is a fake number\n"; } # ----- $_ = "My favorite cop is Ponch\n\nBut some crazy people like John."; if (/Ponch.*John/s) { print "Ponch is mentioned somewhere on this page before John\n"; } # ----- $_ = "The number on the wall was 867-5309, Tommy said"; if (/\b[0-9]{3}-[0-9]{4}\b/) { print "This looks like a telephone number\n"; } # OR: if (/ \b # word boundary [0-9]{3} # first 3 digits - # customary hyphen [0-9]{4} # next 4 digits \b # word boundary /x) { print "This looks like a telephone number\n"; } # ----- $_ = "My favorite cop is Ponch\n\nBut some crazy people like John."; if (/ ponch .* john /six) { print "Ponch is mentioned somewhere on this page before John\n"; } # ----- my $tv_show = "The Brady Bunch"; if ($tv_show =~ /brady/i) { print "Who's your favorite Brady?\n"; } # reading through a piped-in file while (<>) { if (/\b(\w+)\s+(\w+)\b/) { print "word 1 was $1 and word 2 was $2\n"; } }