Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Opening and reading file

by poj (Parson)
on Jan 15, 2012 at 21:21 UTC ( #948020=note: print w/replies, xml ) Need Help??


in reply to Opening and reading file

if ($msg =~ /!state\s+(.{2})/){ my $search = uc($1); my $result; my @list = <DATA>; for (@list){ chomp; my ($id,$name) = split /\|/,$_; if ($id eq $search){ $result = "State $id = > $name\n"; last; } } # if ($result){ print $result; } else { print "Could not find state $search\n"; } } __DATA__ CA|California ME|Maine NY|New York TX|Texas UT|Utah
poj

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948020]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2016-12-05 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (82 votes). Check out past polls.