Hi there.

Er, I first had to find out that this is a mailing list and no newsgroup. I signed at google groups, posted messages and wondered why they actually are not there when I browsed the list at nntp.perl.org. At www.perl.org I actually figured that this is a list. Ohh dear. So if the messages that I've send through google are arriving after all, i'd like to appologize just now. :)

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

Just calling perl subroutines from C in't a problem with embedding a Perl Interpreter. But passing arguments from and to the perl script over pipe isn't what I want. If I could pass and get arguments or variables in a OO manner that would be great. If nothing else works, I probably have to deal with the pure C solution. But I first wanted to test other possibilities. 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>

The -namedObject: returns a nil pointer, so something goes wrong there, but I couldn't figure out what. As you can see I sent the -useLib: message and extended the library search path to where the SomePerl.pm module is. So I guess the module itself should be found.
Can someone please give me some hints?

Thx,
Manfred


Reply via email to