I'm trying to write a script with Perl and I'm having trouble with getting switch to work. I have ActiveState ActivePerl 5.8 installed, but when I loaded the Perlscript_version plugin trying to troubleshoot and verify which version of Perl I have loaded it says:
PerlScript version = 5.008007
and I can't get PerlScript_Version:help or scriptversion aliases to work
There actually is no scriptversion alias, I don't know what happened to this plugin, I think it used to work.
Anyway, all of the mushclient calls need a $world-> infront of them. I don't know why the note works upon installation.
Also, the three lines in the script (the ones between the brackets) should have semicolons on the end of them.
You can find the version by using $] you don't need to worry about using this plugin, which doesn't seem to be too effective in anything at the moment.
It would probably be a better thing trying to figure out what's wrong with switch.
Wait, switch? Switch as in, selecting a bunch of case statements? Also known as select/case? Or, some other switch thing all together?
Perl doesn't have one. Use if elsif else groups (and no, there is no second e in elsif). If you need to use the drop through abilities of a switch statement, post your situation, and we'll see if we can't figure something out.
Thanks, I doctored up the plugin and got it to work.
The switch I was trying to use is in the documentation that came with the activeperl, and I checked the lib folder and the switch module is there but I guess the way mushclient uses perl for scripting it isn't able to see the module or something. In the documentation it shows the usage as this:
use Switch;
switch ($val) {
case 1 { print "number 1" }
case "a" { print "string a" }
case [1..10,42] { print "number in list" }
case (@array) { print "number in list" }
case /\w+/ { print "pattern" }
case qr/\w+/ { print "pattern" }
case (%hash) { print "entry in hash" }
case (\%hash) { print "entry in hash" }
case (\&sub) { print "arg to subroutine" }
else { print "previous case not true" }
}
When I take out the switch the script runs fine. I'm using ActivePerl 5.8.7.813