Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?
User Journal

Journal Journal: More perl...

More wodges of code now. This nicely shows the autoboxing of Scalars and actually does something useful that you /can't/ do easily with the standard .NET framework :).

namespace PerlEmbedExamples {
    using System;
    using Perl;

    class IMAPExample {
        public static void Main(string[] args) {
            Console.WriteLine("Embedding Perl within Mono - IMAP Example");
            Console.WriteLine("(C) 2004 Rich Wareham\n");

            Interpreter interpreter = new Perl.Interpreter();
            interpreter.Embed(); // Do the required magic for Perl to be // sitting listening to us.

            try { // Ensure we have the Mail::IMAPClient package.
                interpreter.Require("Mail::IMAPClient"); // Create a new connection
                Scalar client = interpreter.CallClassMethod("Mail::IMAPClient", "new",
                        "Server", "charon",
                        "User", "rjw57",
                        "Password", "XXXXXXXXX"); // Check for success - autoboxing of Scalars to bools.
                if(!client) {
                    Console.WriteLine("Could not log into server.");
                } // Get list of subscribed foderss.
                Scalar[] folders = interpreter.CallMethod(client, "subscribed",
                        Interpreter.CallFlags.ArrayContext); // List them to STDOUT, note autoboxing of Scalars to strings.
                Console.WriteLine("Subscribed to {0} folders:", folders.Length);
                foreach(string folder in folders) {
                    Console.WriteLine(" -> {0}", folder);
            } catch ( PerlException e ) { // If there is some Perl error, catch it and report.
                Console.WriteLine("Error was thrown: {0}", e.Message);

User Journal

Journal Journal: Sickness

Well I've been playing with embedding Perl within C# and have managed to write the first 'useful' program. The following is a re-write of the LWP simple test program in C#.

namespace PerlEmbedExamples {
    using System;
    using Perl;

    class LWPExample {
        public static void Main(string[] args) {
            Console.WriteLine("Embedding Perl within Mono - LWP Example");
            Console.WriteLine("(C) 2004 Rich Wareham <richwareham@users.sourceforge.net>\n");

            Interpreter interpreter = new Perl.Interpreter();

            try {
                Scalar ua = interpreter.CallClassMethod("LWP::UserAgent", "new");
                interpreter.CallMethod(ua, "agent", "Mozilla/6.0");
                Scalar req = interpreter.CallClassMethod("HTTP::Request", "new",
                        "GET", "http://example.com/");
                Scalar res = interpreter.CallMethod(ua, "request", req);

                if(interpreter.CallMethod(res, "is_success")) {
                    Scalar content = interpreter.CallMethod(res, "content");

                    Console.WriteLine("Content:\n{0}", content);
                } else {
                    Console.WriteLine("Request failed.");
            } catch ( Exception e ) {
                Console.WriteLine("Error was thrown: {0}", e.Message);

You may well ask "Why bother?". Well actually I've been wanting to write some code in C# for a while but there just aren't enough utility libraries/classes about under sufficiently good licenses. I could do a load of P/Invoke magic to make use of C-libraries but that invoves a) recompiling on each platform and b) only using C-libraries available on multiple platforms. Using Perl gives C# immediate access to the vast wealth of modules on CPAN.

This makes wrapper classes around Perl modules pretty easy to implement :). Also the magic boxing and unboxing ability of C# means that I can use 'Scalar's pretty much just like 'Variants' in VB (which is more or less a good thing, I think).

User Journal

Journal Journal: Not much

Slow news days today and yesterday. Not much to report. Managed to get into work every dayt his week though. Thank fsck its Friday :).

Progress on MasonMail (my attempt to make webmail clients not suck) is going well. Its actually very usable for reading e-mail. This I suspect will be a plateau point, much like where DM is (I seriously need to spend some time on that).

On other coding fronts I'm re-discovering mono and decided that the next project I code which doesn't just need a Perl script will be written in C#, attempting to use as much managed code as possible.

In the vein, I'm just writing some ebuilds to let me play with System.Drawing and friends. Should be exciting.

User Journal

Journal Journal: Desks

Just finished moving desks. I now have a window and 70 quid that I found hidden in all my crap. Woohoo.

That aside I need to do a bit of work now. Got corrections to The Paper as well as a few chapters of a book to read. Its all go here!

User Journal

Journal Journal: Stuff

Went out with James last night. Poor dear has had Jenni go up to Scottie-land and leave him on his own. It was a very 'chilled' night, basically spent in the MCR watching telly.

Woke up early this monring, then went back to bed and fell totally asleep until 1pm. Guess I'm not quite sorted yet. Came in and had fun playing with itteration 2 of The Paper.

Dunno whats happening tonight. Hopefully something relaxing...

User Journal

Journal Journal: Mondays...

Well, not much of an entry for the weekend :).

On Saturday Jennie and I got up early and went around bits of the National Science week stuff here with my parents and their French friends. All very nice and very tiring. Still my mother hinted at some exciting financial arrangements so things could be good on that front.

In the evening was Improv curry. There is definately a critical mass of improvised comedians and we attained it. Jokes were flying all night and, with comedians, when the ball is dropped someone not only picks it up and runs with it but propells it somewhere towards the far-reaches of the Universe as well.

After the curry, everyone decamped to the Pub to have beer and festivities. After the beer staret flowing an ambitious plan was crafted 'Impro 24', almost exactly the same idea as the series '24' but improvised, back to back, for 24 hours. Yes, a crack team of comedians will risk certain brain damage just for entertainment. OTOH, it being May Ball season, most people will be used to random sleep patterns.

Eventually we ended up in the ADC bar talkign about 'Impro 24' and attempting to work out where we could hold such a thing. Ideas at this point were not forthcoming.

Around half-midnight Jennie and I finally moved to our beds and I fell asleep and didn't wake up until Sunday afternoon -- a good night.

Sunday was pretty boring, with not much happening and now its Monday. Wondering about moving desks actually. A nice one has just become available...

User Journal

Journal Journal: Comedy

Gig last naight at Homerton went OK. It was odd working with people we haven't worked with before - they are so unreliable. Right in the middle of '3 words' there was the biggest block I have ever come accross :(.

The audience seemed to like it and it all managed to come off OK in the end. Jennie and I commented to each other how snobby we have become, I guess we assume everyone is going to be as professional as Rich and Alex. Sarah was amazingly thespy at the end and gave everyone cards. Good god!

Marisa, Ashleigh, Jenni and James were there and seemed to enjoy themselves. James said he actually preferred it to Improwar. Of course I keep going over all the mistakes in my head but I reckon its fine really.

Two supervisions today which I'm doing the work for now. Should be OK.

Jennie didn't get the ADC job either :(. Big hugs to her.

User Journal

Journal Journal: Dropping off

Not too wonderful today. Feeling a bit under the weather. Probably perfectly timed to be ill over the weeked :(. Improv tonight which might wake me up a little though :).

The running order sent out yesterday prompted quite a few comments from participants -- mostly identical so that should be resolved soon.

I should also get around to replying to the e-mails about my OSNews.com article soonish....

User Journal

Journal Journal: Improv

Got the proposed running order for tomorrow's improv show through. Its a wee bit odd, both in pace and assignments, but then I reckon that because Sarah hasn't planned, or appeared in, an improv show with us before. There appear to be some stalling points on odd choices of games but seems OK. Will be playing with some people we haven't worked with much before which should be exciting...

User Journal

Journal Journal: Supervisions

Lots of buggering about required today. Need to buy some Formal Hall tickets, pick up superivision work and, possibly, grab some Grad-lunch. On the other hand I'm feeling pretty bad today. Might leave the ticket buying to this evening - I still need to find someone to buy some for me.

User Journal

Journal Journal: Geek cred 1

Well now my essay has reached geek nirvana (or maybe a geek nadir) and been posted to /.. I've been having fun reading the usual slashbot comments.

User Journal

Journal Journal: Robinson 2

Oh dear... Robinson has got back to me about wandering decs. Wonder how Jennie did. Update: the 'oh dear' was me worrying that Jennie didn't get it whilst I did. That appeared to be the case so, since it wouldn't be fun without her, I'm turning them down. It seems wrong for an actor to turn down their first job :).

Right then. That out of the way (and myself awake finally) lets see what I should do today. Playing with BrookGPU seems the primary task but finishing reading Linux Journal might be good as well.

User Journal

Journal Journal: Catholics and OSNews

Just come back from the Catholic gig and the workshop. The workshop was cool, some new blood coming along to play some games and fun was had by all. Sarah (the Whose Line... organiser) was there giggling away and writing notes, so Thursday should be good.

The gig tonight was interesting. It was just Jennie, Rich F, myself and Alex on stage with the ever-wonderful Mr Chris Webb *applause*. It was the first time we've done a gig with so few people and was quite exciting. The audience were mellow Christian drunks so they were polite but not too active.

Robinson hasn't yet got back to us about May Balls which is either Good or Bad. Oh well, never mind.

Finally the exciting news. An essay I wrote has appeared on OSNews which is exciting...

User Journal

Journal Journal: TODO list 3

Grrr. Konq. just crashed half way through this entry. I really need to get SuSE up to date. This is an ancient version of Konq. here. Update: no curry tomorrow any more. Saturday is the new day...

Anyhow. Today hasn't had much happening so I'll write my TODO list. In no particular order today I must

  • Send off New Hall work DONE
  • Organise New Hall supervisions WAITING (for email)
  • Organise a hanging supervision DONE
  • Sort out something to do tonight (see later) DONE (with extreme cunningness)
  • Reply to improv curry email DONE (by Jennie)
  • Merge DM changes DONE

In addition I am taking an improv session tonight to get some practice in for the Catholic gig and for Whose Line... on Thursday. Its an Improv week this week since there is also Improv Curry (pause while I add item to TODO) on Tuesday.

Last night I also had a curry, there was a special ent on in the MCR before the film (which Jennie and I avoided). We also get to know today about being wandering decs at the Robinson Ball. TBH I just enjoyed the audition so I don't really mind one way or the other. I know I represented myself and what I do well and that it was bloody good as well. If its not what they want then so be it.

User Journal

Journal Journal: Updates

OK, Catholic gig is postponed until tomorrow which is a wee bit annoying as it might interfere with the practice we're having at Kings. OTOH it will be great to get warmed up before the show.

Just come back from the autitions for Robinson Pirates and Jennie and I at least think it went OK. Ran out of time but then I think the description of the ending was better in their heads than it could ever have been acted. We also cunningly split the 10 minute scene into 2 or 3 sub-scenes without an obvious cut so as to make it non-obvious we were treating it like Improwar!

Jennie and I were in a group on our own which we think was better because a) the stage prefers two people on it b) we're all good enough at improv to known that one person != one character and c) we known the rules of improv. While waiting in the waiting room we saw the other groups making classic mistakes, lack of chivalry, NES, blocking and over-planning 'here I will say "you scurvy knave" and then you say "I will thrash you"' and so on.

We'll see tomorrow how it goes...

Slashdot Top Deals

There is no likelihood man can ever tap the power of the atom. -- Robert Millikan, Nobel Prize in Physics, 1923