Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Perl / October 2005



Tip: Looking for answers? Try searching our database.

Howto access Perl Objects from Cocoa

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Manfred Bergmann - 27 Oct 2005 00:19 GMT
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
Sherm Pendley - 27 Oct 2005 19:32 GMT
> I am almost new to Perl. I like it and tried to use it in some of  
> my Cocoa Projects.
[quoted text clipped - 3 lines]
> what I try to do. I tested it with CamelBones first. Maybe someone  
> can tell me whether this would be possible with PerlObjCBridge, too.

Looks like your message to nntp.perl.org finally got here. ;-)

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Manfred Bergmann - 27 Oct 2005 23:16 GMT
Am 28.10.2005 um 04:32 schrieb Sherm Pendley:

>> I am almost new to Perl. I like it and tried to use it in some of  
>> my Cocoa Projects.
[quoted text clipped - 5 lines]
>
> Looks like your message to nntp.perl.org finally got here. ;-)

Yea, took some time but it finally arrived.
Lets see if the messages sent through google also will arrive. I have  
sent one on the 23th. :/
I really don't understand this. Are the messages sent through google  
only available for users who browse the news with google?
Anyway.

I've posted my small CamelBones example in a german OSX developer  
forum and some guys where very happy about it.

Manfred
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.