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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Checking input against known
by McDarren (Abbot) on Aug 02, 2006 at 04:16 UTC |