Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

claes (1758)

claes
  (email not shown publicly)
http://www.surfar.nu/
AOL IM: claesjacobsson@mac.com (Add Buddy, Send Message)

Journal of claes (1758)

Monday August 18, 2003
08:25 AM

cross reference of entire CPAN

A couple of weeks ago I spent some time in London after YAPC::Europe. At an emergency london.pm social meeting we had a few drinks and then Sky started handing out projects to us who had nothing to do.

I got assigned the fun task of cross-referencing CPAN!

Basiclly, it analyses source code - finding what other packages it uses or requires, what subroutines it declares, what functions and methods it calls and what packages it defines. From this information a database is built holding references.

In the web-interface, you can browse the distribution and if a file is indexed you can have a look at the source. When it lists the source, each connection (like a use, call etc) are linked and if you click that link you'll end up in the symbol page. This is where it's getting interesting. The symbol display page shows in what file(s) the symbol is define as a package, declared as a subroutine or called.

You can also search for symbols which is great if you know the name of a function but you don't know in what distribution/module it is declared in.

Anyway, doing source analysis of Perl-code is extremlly difficult, and it won't handle some of special things one can do. I wish I had a better way to do it than with regular expressions. Only perl can parse Perl!

I plan to have a public demo site up today or later this week. The URL will be posted in my journal.

Hopefully, you guys will find this useful.

/Claes
Friday August 01, 2003
08:51 AM

Travel report

I'm finally back in Stockholm after 10 days of conference/vacation. YAPC::Europe was great, huge amount of credits to the Paris Perl Mongers. I'm already looking forward to next years YAPC::Europe in Belfast.

After Paris, I took the EuroStar up to London. It was supposed to take 2 1/2 hours, but ofcourse the train going to Paris broke down at Ashford International so they had to take our train back to Paris and we had to wait while they fixed their train to take us to London. Atleast I didn't have to wait 4 hours as some of the London Perl Mongers did.

Once in London, a friend met me at Waterloo Station and we took a cab up to a swedish pub. Once there, we found it was occupied by a private party (Bummer), so off to McDonalds for some dinner. It is without doubt the most expensive BigMac & Co I've ever eaten. Later that night we went to a pub in Chelsea.

On monday, I went to stay with sky in his apartment and do some sightseeing. Took the bus from Old Street down to Waterloo to catch Matrix Reloded on IMAX, but they only screen it in the evenings. So I walked over to Tate Modern, cross the millenium bridge and up in St. Paul's Cathedral. 600 stairs makes me really tired. After some random walking in London, I went to see sky again.

On tuesday, more random tourist activities.

On wednesday evening, there was a emergency London.pm social meeting because I and R. Geoffrey Avery were in town. Lots of beer and booze and sky managed to hand out homework for those who had little to do.

Thursday and it was time to fly back home. Took the train from Paddington out to the airport and got lost in the terminals. Managed to find my way to the SAS check-in after a while. After going thru security check and not beeing searched I was kinda suprsised, because I thought they had tighten up security. But when entering the gate, they randomly (yeah right, eat my shorts) selected me for a security check. Two people who had checked-in didn't board the aircraft, so they had to unload all luggage and remove theirs so we were an hour late away from London.

Well, that's about what I've been up to.. now it's time to do some programming (and play SimCity 4 ofcourse).

/Claes

Thursday June 19, 2003
04:01 AM

YAPC::Europe talks

Sweeeeet, both of my submitted talks for YAPC::Europe 2003 got accepted.

I'll be doing two presentations this year, Making Applications scriptable and Filter development for Imager.

However, I need a wacky idea on what the Imager plug-in should actually do. I have some ideas of my own, but yours are probably better.

If you have one, please either send it to imager@surfar.nu or post a comment to this journal entry.

See you in Paris,
Claes

Friday May 16, 2003
05:38 AM

Stag party

Last night we arranged a stag party for sky, it was lots of fun.

Me, kane, sky and 6 other friends cruised in a limo to the climbing place where sky climbed some walls. Then we headed home for a three course dinner I prepeared, and afterwards we had cigars & booze. Later in the evening we ended up drinking beer & vodka in their sauna.

I hope everyone is more or less alive today.

Tuesday May 13, 2003
07:07 AM

Tales from the crypt

It's sunny and kinda warm outside here in Stockholm, wtf am I doing at work?

Anyhow, I installed SquirrelMail on my mailserver yesterday because I wanted a web-interface to my mail. It's nice and all that, except it's written in PHP and really slow with lots of mail in the inbox. Are there any nice mod_perl based web-mail solutions or will I have to write one myself?

Next thing I want is an Apache module for publishing my Keynote slides like the HTML export feature in Microsoft PowerPoint. I wrote some code to objectify the presentation.apxl file, it could probablly end up in something useful. This could, ofcourse, be used for other things as well, like rendering each slide with Imager or like.

My implementation of the li/rpc protocol (http://lirpc.berlios.de/) is comming along fine. I've renamed it to li/rpc-e (e for enhanced) since it adds a number of features not found in li/rpc. Hopefully, I can post it on CPAN sometimes next week.

Oh, and I need to learn python and tcl.

/Claes

Tuesday March 04, 2003
06:30 PM

on Net::Java::RMI and Serialization

Several people have told me the past days that I'm basiclly nuts. I dunno why, but since I can't find any arguments to prove them wrong they are probablly right.

Well, I think it all comes down to my fascination of doing serialization. So, I've listed my top six libraries/frameworks/technologies (note, some of these do not do cross-platform or cross-language communication).

1: use Storable qw(freeze thaw)
What can we say? Storable is reasonably fast and creates pretty compact binaries.

2. YAML
Compact readable dumps, easy to debug, easy to handcraft.

3. NSCoding protocol in Cocoa/GNUstep
I actually like this, it gives me full control of what to serialize. And I'm a big fan of Objective-C too.

4. XML
Can be compact and nice, can be huge and ugly. It's what you make of it.

5. Roll your own binary
Not a bad alternative. Autogenerating XS code from XML is fun.

9999: JAVA built-in
java.io.ObjectOutputStream, java.io.ObjectInputStream, java.io.Serializable and java.io.Externalizable says it all. Backwards-compability is a biatch. Doing it in Perl is even more a biatch, but it can be done.

Well, that list pretty much sums it up, don't we think?

Cheers, Claes
Monday January 27, 2003
04:23 PM

Java/Perl RMI

I've been investigating Java RMI lately... expect wicked stuff.

Wednesday September 05, 2001
10:23 AM

Perl - Java - Perl and stuff like that

[ #761 ]

During the last few days, i've been doing some heavy programming incorporating execution of Java code inside our Content Management System. Except the possiblity to run Perl and JavaScript in the webpages the system creates, the marketing people also wanted native Java support. At first, this sounded like an "almost" impossible task (since i had 3.5 working days to fix it). But nothing is impossible =)

Inline::Java fixes the problem to run java inside perl, but once you want java code to call perl subrutines (or methods) things get harder. So i realised it was time to dig into JNI (Java Native Interface) and mix that with perl API calls. Inline::Java is really really nice, but didn't really do what i wanted so i ended up using Jvm.pm which is just an interface to JNI Invokation Interface. We wanted to wrap our perl classes inside Java and that was the problem. This is basiclly what i ended up with:

----------------------------------------

# Wrapper Java class
public class FooWrapper {
    int _SVaddr = 0;

    static { System.loadLibrary("FooWrapper") }

    public FooWrapper(int ptr) {
        _SVaddr = ptr;
    }

    public native void printID();
}

# Some JNI code, compiles to libFooWrapper.so needed for System.loadLibrary

SV *get_sv_reflect(JNIEnv *env, jobject obj) {
    SV *reflect_sv;
    jclass class_ref;
    jfieldID addr_field_ref;
    jint addr;

    class_ref = (*env)->GetObjectClass(env, obj);
    if(!class_ref) return NULL;

    addr_field_ref = (*env)->GetFieldID(env, class_ref, "_SVaddr", "I");
    if(!addr_field_ref) return NULL;
    addr = (*env)->GetIntField(env, obj, addr_field_ref);
    if(!addr) return NULL;

    reflect_sv = (SV *) addr;
    return reflect_sv;
}

JNIEXPORT void JNICALL Java_FooWrapper_printID(JNIEnv *env, jobject obj) {
    dSP;
    SV *ref;
    ref = get_sv_reflect(env, obj);

    if(ref) {
        ENTER; SAVETMPS; PUSHMARK(SP);
        XPUSHs(ref);
        PUTBACK;

        call_pv("Foo::printID", G_VOID);

        FREETMPS;
        LEAVE;
    }
}

# Our java code
public class Party {
    public Party {
    }

    public void run(FooWrapper foo) {
        foo.printID();
    }
}

# Some perl code
package Foo;

sub new {
    my $class = shift;
    my $id = shift;

    return bless { id => $id }, $class;
}

sub printID {
    my $self = shift;
    print "ID is: $self->{id}\n"
}

package main;

use Inline ( C => "int get_sv_addr (SV *var) { return (int) var; }" );

use Jvm;

my $party = new Jvm("Party", "()V");
my $foo = new Foo(10);

my $foow = new Jvm("FooWrapper", "(I)V", get_sv_addr($foo));

$party->run("(LFooWrapper;)V", $foow);

----------------------------------------

The real code i wrote throws Java Exceptions if the perl subrutine/method dies =)

Magic =) /claes

Sunday July 29, 2001
12:10 PM

Going to Amsterdam

[ #530 ]

Tomorrow at 4 am, I'll be on my way to Amsterdam and Yapc::Europe, woohooh! /claes

Wednesday July 25, 2001
03:19 AM

make dist

[ #498 ]
It's been a while since my last journal but i've been busy fixing up JavaScript.pm for release to CPAN and writing both docs and my speech for YAPC::Europe.

After many late nights, i finally did a 'make dist' this morning. So, i promise, it will be uploaded today.

If anyone cares to read documentation, there is one over at http://labs.contiller.se/JavaScript/js.html

Enjoy it, i do =)

/c