in reply to Checking input against known

Hi, If I understood your question correctly then try like this,

TIMTOWTDI

use strict; use warnings; my @known = ("foo", "bar", "baz"); print "Talk to me, Goose."; my $input = <STDIN>; chomp($input); my ($in_fla) = grep/^$input$/i, @known; if ($in_fla) { print "You gave us $input, which equates to ".uc($in_fla).". G +ood night, and good luck.\n"; } else { print "Not a match. YET!\n"; } __END__ D:\Workout>perl array.pl Talk to me, Goose.Foo You gave us Foo, which equates to FOO. Good night, and good luck. D:\Workout>perl array.pl Talk to me, Goose.FOO You gave us FOO, which equates to FOO. Good night, and good luck. D:\Workout>perl array.pl Talk to me, Goose.arr Not a match. YET!

Updated: Thanks McDarren.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
Re^2: Checking input against known
by McDarren (Abbot) on Aug 02, 2006 at 04:16 UTC
    my ($in_fla) = grep/$input/i, @known;

    That will not work correctly, as it will match any part of the known strings. For example, it would match "fo", "ar", "z", etc.