HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free and registered users see less advertising! If you just want to browse through the existing questions, just select the forum that you want to visit from the selection below. Otherwise, click here to register!. We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Re:newbie perl question using Net::OSCAR module

Ah yes... I am very bad at commenting and keeping the code, thanks for fixing it up.
too bad PHP::Strings is largely incomplete, and str_replace() (replace a part of a string) and strchr() (search within a string) are not yet implemented, would anyone happen to know the perl equivlants?

Re:newbie perl question using Net::OSCAR module

[quote author=countach44 link=board=9;threadid=8256;start=0#msg74922 date=1070829557]
Ah yes... I am very bad at commenting and keeping the code, thanks for fixing it up.
[/quote]

No problem. If you end up releasing the code as OSS submit it to me and I&#039;ll &#039;clean it up&#039; a bit for you. It can&#039;t hurt

too bad PHP::Strings is largely incomplete, and str_replace() (replace a part of a string) and strchr() (search within a string) are not yet implemented, would anyone happen to know the perl equivlants?

You probably want to use regex. Perl is the king of regex and allows you to do just about anything with a string.

Re:newbie perl question using Net::OSCAR module

Neither of those should work because you are trying to call str_replace() which isn&#039;t a perl function (unless you are implementing your own). You would need to use a search and replace regex instead. The rest of the code looks like it should work with the exception of !warn being a bareword (should be &quot;!warn&quot.

I am going to go step by step through the code and explain whats happening to make sure thats what you are wanting to happen.

Making it OSS is a good idea, but it depends on what this bot is for. If you are making a general bot for fun/utility then open it even on the small scale (with friends or board members). If it is just a small toy with no real want to expand it to do other functions (like email through IM and stuff) then just keeping it to yourself is probably the way to go.

I&#039;m confused at what the str_replace you defined does (it may be the same thing as what i described above)
also i tried getting my bot to warn somebody on a user not defined in $users, and i pulled the same errors with str_replace, meaning the user got past

Re:newbie perl question using Net::OSCAR module

Both operations you&#039;ve described can be done with regexp&#039;s. The definitive guide: http://www.perldoc.com/perl5.8.0/pod/perlre.html is where I learned everything I know abour RE in perl, and I use them heavily every single day for my job. Extremely powerful stuff, if a little gory.

You&#039;ve already been introduced to the &quot;search within a string&quot; part of your query (using the =~ mapping operator). In order to replace part of a string, use the s/pattern/replacement/ operator. It should also be in the perlre documentation. Basically if you&#039;ve ever done pattern replacement in vim it&#039;s very similar.