Hello, i am making an AIM-Bot, and i am very new 2 perl, and i was wondering how i can make the bot recall a file (screenname.emo) and add/subtract a number from that file, when it recieves a specified message. I guess it would go something like this?:
if (! -e "emotions/$victim.emo") {
open (DATA, ">emotions/$victim.emo");
print DATA "0";
close (DATA);
}
if ($msg =~ /^sorry/ || $msg =~ /^srry/ || $msg =~ /^sry/)
{open (FILE, ">emotions/$victim.emo");
$emo = <FILE>;
print DATA "$emo ++ 1";
close(FILE);
return "it's OK.";
}
With "sorry", "srry", or "sry" as the message recieved to the bot. Any ideas? Thanks!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.