Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Perlscript ➜ Script for Text Manipulation with an Alias

Script for Text Manipulation with an Alias

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Jakevanderpuy   (22 posts)  Bio
Date Wed 25 Jun 2003 02:48 PM (UTC)

Amended on Wed 25 Jun 2003 04:36 PM (UTC) by Jakevanderpuy

Message
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;
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 26 Jun 2003 07:25 AM (UTC)
Message
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);


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Dubthach   (47 posts)  Bio
Date Reply #2 on Thu 26 Jun 2003 06:58 PM (UTC)

Amended on Thu 26 Jun 2003 06:59 PM (UTC) by Dubthach

Message
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";
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 27 Jun 2003 12:57 AM (UTC)

Amended on Fri 27 Jun 2003 08:01 AM (UTC) by Nick Gammon

Message
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>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Jakevanderpuy   (22 posts)  Bio
Date Reply #4 on Fri 27 Jun 2003 03:03 PM (UTC)

Amended on Fri 27 Jun 2003 03:38 PM (UTC) by Jakevanderpuy

Message
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.
Top

Posted by Shadowfyr   USA  (1,790 posts)  Bio
Date Reply #5 on Fri 27 Jun 2003 05:27 PM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 27 Jun 2003 08:52 PM (UTC)
Message
The brief answer is, yes you need Perl installed, and don't have. VBscript and JScript is usually installed by default.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


20,614 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.