?

Log in

No account? Create an account

LiveJournal and Perl - Bobson's Bits

Jun. 16th, 2004

12:49 am - LiveJournal and Perl

Previous Entry Share

Well, I haven't posted in a long time... Mostly because I don't like posting about what's going on in my life. I'm too private a person for that to appeal to me. But then what should I write about? I'm open to suggestions...

So I finally have something to talk about.

My Perl skills have improved tremendously in the last two months - it's amazing what working with it on a near-daily basis will do. So when I needed a way to restrict one person's remote access to my computer, while still granting him access to three directories on three different drives, I turned to a perl script... I sat down and wrote out a complete file-transfer mini-shell in perl. It doesn't support much now - you can 'cd' one directory at a time, and 'ls' your current directory (with any switches you want). You can also 'scp' files from those directories, and any scp uploads went to a different (preset) destination. I tested it, then let my friend know that it was working. He logged in... and it failed miserably.
After about 90 minutes of debugging, while my friend was trying to use this shell, I managed to get everything working. Just goes to show that you can never really think of everything that can go wrong with your code. In particular, the shell didn't check to see if the directory existed before letting you cd into it, it didn't handle file names with spaces (of which I have a lot), and the scp stuff was all messed up. I eventually got it working, though, and I'm considering working it into a more robust shell. Not on the level where someone would use it as a main working environment, but maybe to the point where you would set it up to easily give someone limited access. I'm sure there's already shells out there which can do that, and I might go look for them, but I might do it even so, just for the practice.

I'm also working on PerlMUSH - a TinyMUSH-like server written in perl. I'm going to try and make it as compatible as I can, without actually looking at the TinyMUSH code. Currently I'm basing it on MUX 1.5, since that's what I'm most familiar with, but I plan on switching to MUSH 3.0 fairly soon (or never - depends if I ever get around to installing 3.0) - at this point it'd still be an easy switch.
I've got a number of reasons for doing this. I want to know that I can write something that complex. I want the practice and reason to use parts of perl I'd never otherwise use (such as tied variables). I want to see if perl is better for a MUSH than C (assuming my coding skill is up to it).

The last one could probably use some more explanation. From my viewpoint, the MUSH structure of a list of numeric dbrefs, each with an arbitrary number of arbitrarily named attributes perfectly fits the Perl structure of an array of hashes. (For those of you who don't know what that means, an array is a list of sequential numbered items, and a hash is a way of storing a key/value pair, where both can be anything. So I'd store a description of object #2 as "Key=Desc, Value=This is my room!" at the 3rd place in the array (since MUSHes and arrays start with #0). The perl for that would be '$Objects[2]->{Desc} = "This is my room!"'.) Also, with Perl's regular expression support, it ought to be easy to write a regexp engine for MUSH. Search all help files for any arbitrary pattern. Do a search for all objects with "Foo" at the start of it's name, and "Bar" at the end. Maybe even let people write commands which have a regexp match instead of a glob match (* and ? only). I'm not sure how useful any of these would actually be in practice, but it'd be fun to try to write them.

Currently I have a chat-like server which will accept connections, and handle everything except a 'WHO' from a MUSH-like connection screen. You can create new characters, or log into existing ones... but attempting to do anything after that will crash (since I haven't written the routines it's trying to call), and there's no preservation of the database. It will idle you out, if you're inactive long enough, too. The next step is going to be to add locations/contents. After that, I should be able to implement an emit() function, which will let me get pose and say working... Once I've got it up to the level of a standard basic chat server, I'll see where to go next.

Current Mood: accomplishedaccomplished
Current Music: Yuki Kaijura - .hack//SIGN OST.1 - key of the twilight

Comments:

[User Picture]
From:jon_ezra
Date:June 16th, 2004 04:55 am (UTC)
(Link)
Dan...I'm also a really private person , but I still find what to talk about. :-P No using that as an excuse! That's what I did for a while...and originally.
(Reply) (Thread)
[User Picture]
From:tigana
Date:June 16th, 2004 09:37 am (UTC)
(Link)
Wow.. You've come a loooooong way from when I first met you. I'm very impressed. :)
(Reply) (Thread)