Hi there.

I am almost new to Perl. I like it and tried to use it in some of my Cocoa Projects.

First of all. I found there are two approaches. PerlObjCBridge and CamelBones. Unfortunately I couldn't find any examples covering what I try to do. I tested it with CamelBones first. Maybe someone can tell me whether this would be possible with PerlObjCBridge, too.


I played a bit and that's what I figured so far. But unfortunately
I wasn't successfull in creating a CBPerlObject. I tried it from a
Foundation Project.

<objc_code>
#import <Foundation/Foundation.h>
#import <CamelBones/CamelBones.h>

int main (int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // create perl interpreter
    CBPerl *perl = [[CBPerl alloc] init];
    //[perl useWarnings];   // activate warnings
    //[perl useLib:modulePath];
    [perl useModule:@"SomePerl"];
    [perl eval:@"$somePerl = new SomePerl"];
    CBPerlObject *perlO = [perl namedObject:@"somePerl"];

    [pool release];

    return 0;

}
</objc_code>

The SomePerl.pm file looks like this:

<perl_code>
package SomePerl;

use strict;
use warnings;

sub new
{
        my $class = shift;
        my %attr = @_;
        my $self = { %attr };
        return bless ($self,$class);

}

1;
__END__
</perl_code>

What I don't understand is, where do I have to put the SomePerl.pm file
so that code above finds it. I guess it can be somewhere but then I have to explicitly say so by calling [perl useLib:<pathOfPMFile>], right?

The -namedObject: returns a nil pointer, so something ggoes wrong there, but I couldn't figure out what.
Can someone please give me some hints?

Thx,
Manfred

Reply via email to