Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Opening and reading file

by poj (Priest)
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


Comment on Re: Opening and reading file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2015-07-02 02:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls