if($msg =~ /!info\s+(.{6})/) { my $info = $1; my $database = "list.txt"; open FILE,"$database" or die "Error Opening: $!"; my @results = <FILE>; close FILE; my $var = 0; my $chkvar = 0; foreach my $url(@results) { if($url =~ m/$info\|(.*)\|(.*)/) { if($var == 0) { $var = 1; sendmsg($irc_socket, "PRIVMSG $channel &#9 +219;4,1[&#9219;0,1BANK&#9219;4,1]&#9219;9,1 $1"); goto finish; } }else{ $chkvar = 1; } } if($chkvar == 1) { sendmsg($irc_socket, "PRIVMSG $channel &#9219;4,1[ +&#9219;0,1BANK&#9219;4,1]&#9219;7,1 Could not retreive bank"); } finish: }

i have this piece of code from an irc bot and what it does it read the first 6 digits from the file when someone types !bank 123456 and display whats after it.. example of text file:

518767|CAIXA ECONOMICA FEDERAL|LA BRA BRASILIA |BRAZIL|

Now I had a question, since im no guru at all in perl. How oculd I change this function to say like the command be !state and the person says: !state NY

it reads from the file and it returns the results as State NY = > New York.

ive tried the same concept as above and made the abbreviations of the states and text file looking like: NY|New York but did not have any sucesss.. could someone point me in the right direction?

Update: Thanks


In reply to Opening and reading file by fame

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.