logo       

Using Perl in Cocoa: msg#00042

Subject: Using Perl in Cocoa
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





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe