Script for Text Manipulation with an Alias

Posted by Jakevanderpuy on Wed 25 Jun 2003 02:48 PM — 7 posts, 27,954 views.

#0
The point in this case is to take input entered after the word 'say' (minus quotes) and randomly capitalize all letters in the string, then send string and ansi codes to world. I actually taught myself Perl scripting last night while writing this script, so it's probably bound to have errors, being my first script ever.

I also need help with actually getting the say alias to work. The name of the script is InsaneText.pl
Do I need to call a variable in the alias somehow? Like $new_str? (see code below for details)

-----------------------------------------------------------
Ex.
Input of the following:

say Hello there Nick Gammon.

Would be changed to something like:

say $2$I hELlo THerE NiCK gAMMon.

Then the ^ above would be sent to the world.
----------------------------------------------------------

Here's what I have right now. The first and last lines are just stuff I made up...I don't know the context for sending and recieving things from the world.

-----------------------------------------------------------

$input_str = world.input;
$top = 2;
$pos = 0;
$num = 0;

while ($pos < length $input_str){
      $num = int(rand $top);
      $char = substr($input_str, $pos, 1);
    if ($num ==1) {
      uc $char;
      } elsif ($num ==2) {
      lc $char;
    }
      $new_str .= $char;
      $pos++;
}

world.send = $new_str;
Amended on Wed 25 Jun 2003 04:36 PM by Jakevanderpuy
Australia Forum Administrator #1
The input to the script is in the alias arguments - see the supplied example script file for examples of aliases that call scripts.

As for sending, you would send the result like this:

$world->send ($new_str);

In recent versions I think you could omit the world bit, and do this:

Send ($new_str);

#2
La dee da, I'm bored...so here's my more perlish way of doing your text manipulation. :P Feel free to ignore me, but your Perl looks C-ish to me!


$input = "Hello there my name is Nick Gammon.";

foreach $x (split(//, $input))
{
	$x = lc $x;
	
	if (int(rand 2) == 1)
		{ $x = uc $x; }
	
	$output .= $x;
}

print $output . "\n";
Amended on Thu 26 Jun 2003 06:59 PM by Dubthach
Australia Forum Administrator #3
Putting it all together (or should I say: PUttIng it ALL tOGeTheR), you can do the whole thing in an alias without a script file, by sending to "script", like this:


<aliases>
  <alias
   match="say *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>$input = "%1";
$output = "";

foreach $x (split(//, $input))
{
 $x = lc $x;	
 if (int(rand 2) == 1)
  { $x = uc $x; }	
 $output .= $x;
}

Send ("say $output");</send>
  </alias>
</aliases>

Amended on Fri 27 Jun 2003 08:01 AM by Nick Gammon
#4
Thanks for the help, all.
It's refreshing to have people respond to posts with valid questions.

But...what does this mean?
---------------------------------------------------------

Error number: -2147221005
Event: finding CLSID of scripting language "PerlScript"
Description: Error -2147221005 occurred when finding CLSID of scripting language "PerlScript":

Invalid class string

Called by:
---------------------------------------------------------

I suppose this means that I don't have Perl installed on my computer, right?

Is there any way to get the *.pl file which is Perl itself installed or downloaded without going through the Activestate install prog?

For example, if I don't have rights to install Perl on a Windows 2000 machine what can I do?

--------------------------------------------------------
^ Ff that isn't the problem then what exactly is the .pl file Mushclient is looking for supposed to include?

I feel stupid but this is just me beginning.
Amended on Fri 27 Jun 2003 03:38 PM by Jakevanderpuy
USA #5
Umm. Like usual Ms tries to confuse you. It isn't a .pl file it is looking for but a .dll. The reason it says .pl is that the error occured trying to run one. That said, if you don't have admin access to the machine, odds are you can't install the script engine. You may have to use something that is installed like VBScript or Java. Assuming they even are, but if you use the machine for browsing, then they should be there.
Australia Forum Administrator #6
The brief answer is, yes you need Perl installed, and don't have. VBscript and JScript is usually installed by default.