Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Checking input against known

by GhodMode (Pilgrim)
on Aug 02, 2006 at 04:03 UTC ( [id://565148]=note: print w/replies, xml ) Need Help??


in reply to Checking input against known

Does the following code do what you need? It's basically what BrowserUk recommended, but lc is better than uc. (... because I said so!... and, besides, I wrote it before I saw BrowserUk's message! :)) ...

use strict; use warnings; my %known = ( "foo" => "FOO", "bar" => "BAR", "baz" => "BAZ", ); while ( <STDIN> ) { chomp; my $input = $_; for ( keys %known ) { if ( lc($input) eq $_ ) { print "You gave us $input, which equates to " . $known{lc( +$input)}; print ". Have a nice day\n"; } } }

--
-- Ghodmode
Blessed is he who has found his work; let him ask no other blessedness.
-- Thomas Carlyle

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://565148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found