[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Perlscript
. . -> [Subject]  Learning Perl
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

Learning Perl

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

Posted by Toruk   (15 posts)  [Biography] bio
Date Sun 20 Apr 2008 12:30 PM (UTC)

Amended on Sun 20 Apr 2008 12:32 PM (UTC) by Toruk

After thinking about what program language to learn how to script in I've finally came up with the descion to use Perl. R

Im reading "Learning Perl, 4th edition" at the moment and I'm hoping that learning perl and using it to make scripts with the client will be something that does not turn out to a major headache.

But to get to the point, If anyone knows good tutorial sites or has a reference of good books to learn for a begginer in Perl. I know I can use google to search but considering there is alot of sites out there to choose from Someone might now a good one off hand instead of me having to pick and choose.

And this is my first language I've choosen to learn. So hopefully I didn't make the wrong choice.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Sun 20 Apr 2008 06:56 PM (UTC)
If you have nothing much invested in Perl, and are flexible in your decision, I would strongly recommend that you try learning Lua instead. It is an easier language with far fewer idiosyncrasies, and besides is more supported on this site. Although I like Perl because I've known it for quite a while, I would not decide to use it in anything larger than a few lines of code.

I would recommend the book "Programming in Lua", available for free online:
The manual is also available but it is not really a tutorial, and more of a reference:

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

[Go to top] top

Posted by Nick Gammon   Australia  (21,564 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 20 Apr 2008 09:22 PM (UTC)

If anyone knows good tutorial sites or has a reference of good books to learn for a begginer in Perl.

I don't really know, sorry. There are heaps of sites and books, so it probably is a case of getting a good one for you which might not be one I would recommend, as I have been programming for years. Different books, and web sites, are tailored to different levels of initial understanding. For example, one site might say "this will create a lookup table with a string key". Some people might say "Ah, I know what that is", but others would say "a what with a what?" - in which case you want a book/site that explains in more detail.

Perl is certainly a mature language, it has been around for a long time, and there are many, many resources to help you learn it.

Having said that, I would agree with David that you are probably better off starting with Lua. The problem with Perl (apart from the fact that the language syntax is, IMHO, slightly obscure) is that it isn't really designed as a script language to be called by the Windows Script Host. Now I know the Active Perl people have made a version that does work with the WSH, but in places the extra complexity can add even more obscurity.

As an example, I will look at how you print (in a script) all the MUSHclient variables in a world. See this page for the function documentation:


The Lua version is very simple:

for k, v in pairs (GetVariableList()) do 
  Note (k, " = ", v) 

The VBscript version isn't too bad, as WSH was really designed around VBscript:

varList = GetVariableList

If Not IsEmpty (varList) Then
  For Each v In varList 
    Note v & " = " &  GetVariable (v)

End If

The PerlScript version starts to look messy:

foreach $item (Win32::OLE::in ($world->GetVariableList))
 ($key, $value) = ($item, $world->GetVariable ($item));
 $world->Note($key . " = " . $value) if (defined ($key));

The problem here is that an array (in this case a list of variables) has been generated as a Visual Basic "variant" type, which Perl does not natively support. Thus you have to use a special function (Win32::OLE::in) to get at items in it.

Certainly you can use Perl if you want, and some of the posters on this site know Perl and will be happy to help you.

Perhaps first browse through the functions documentation:


Most of the MUSHclient functions described there have example snippets in each language. See if you feel comfortable with the Perl ones, before committing too far to that language.

Good luck.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Toruk   (15 posts)  [Biography] bio
Date Reply #3 on Tue 22 Apr 2008 12:28 PM (UTC)
Hmm at first I was going to learn LUA went through some tutorials and it was pretty easy. I got into perl and it seem a little harder to work with. So I think ill learn lua then in the future try taking a look at perl or another language.

Thanks for the input guys.
[Go to top] top

Posted by Toruk   (15 posts)  [Biography] bio
Date Reply #4 on Tue 22 Apr 2008 04:54 PM (UTC)
Yeah I seem to be understanding Lua alot more then I was Perl. And so far everything I needed to script has turned out simple

except a way to pause my speedwalk and resume it when I say so but I found a script on the forums for that. Sooo everything is gravy for now :)
[Go to top] 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.


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

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]