Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript to PERL

Name: JimiHendrix !qHyjmd9XCE 2009-02-20 16:07

sup /prog/,
I was hoping you could help me with perl syntax and code.
I'm trying to remake this(please disregard the name of the blog):
http://frozenvoid.blogspot.com/2008/12/text-case-randomizer.html
into an Xchat scrip by using PERL.
The problem is I don't know PERL, but have been doing some reading and have learned some things so far but hoped asking here would be faster.
Here's the code I copypasted from a script to change text color to rainbow colored and edited somewhat to change it to randomize text:

package IRC::Xchat::TxtcaseRand;

IRC::register("xchat txtcase", "0.1", "", "");

sub txtcase{
    $i=0;
$_=shift@_;
chomp;
s{(.)}{       "\cC" . (($i++%14)+2) . "$1"      }eg;
#$_=$_."\n";
IRC::command ("/say $_");
        return 1;
}


IRC::add_command_handler("case", "IRC::Xchat::TxtcaseRand::txtcase");

my first question:
1. Doesn't $_=shift@_; and chomp; do the same thing?
2. I suppose this > s{(.)}{       "\cC" . (($i++%14)+2) . "$1"      }eg; is what changes the text color, how would I convert function randomcase(text,a){if(isNaN(a)||a>1||a<0){var a=0.5};var res=[];for(var i in text){
if(Math.random()>a){res[i]=text[i].toUpperCase()}else{res[i]=text[i].toLowerCase()}};return res.join("")}
to the syntax that PERL would recognize and replace it in the code?
3.         return 1; means, return to first line of code right?

Name: Anonymous 2009-02-21 1:16

True. Since OP is already in classes, it's going to be kind of a crunch, but OP needs to play with this shit a lot rather than just doing school work as assigned (also important, of course). CS people are lucky enough to be able to do this, since computers are everywhere and compilers are free. You've got professional facilites available to you. Just imagine needing to purchase thousands of dollars of equipment before you could write a proper program. That's how it is in most fields. You CS kids don't know how good you have it.
 
 OP, I want to see you reading at least one CS paper per week, and learning every living language you hear about well enough to read it. You can study the history of programming in your spare time. If you care about being successful in the field (not just grinding out programs that work often enough to get okayed for deployment, but writing good programs), this is what you'll be doing.
 
 You have no idea how often I'm talking to a CS major and find myself delivering a lecture rather than having a discussion. You and your peers are fucking clueless, and it's all your fault for not reading and not practicing, and above all, not knowing how to consult documentation.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List