perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thompson, John" <jth...@midwestern.edu>
Subject RE: Execute({ object => '...' })
Date Tue, 27 Jul 2010 17:57:39 GMT
OK, so I've decided to try to use import instead. I'm seeing this error:

 

--- embperl2.pl ---

use Embperl;

 

Embperl::Execute({ inputfile => 'test.epl', 'import' => 1 });

head();

 

--- test.epl ---

[$ sub head $]

    head

[$ endsub $]

 

main

 

---

 

%perl embperl2.pl

[14900]ERR:  72:  A Embperl sub is called and no Embperl request is
running   

$Embperl::req undefined DOM.xs 284 at
/home/carsids/jthomp/perl/test/test.epl line 11.

 

I thought maybe it'd help if I was running this inside of an Apache
request (I'm using CGI), but I get the same error.

 

 

From: Andrew O'Brien [mailto:andrewo@oriel.com.au] 
Sent: Tuesday, July 27, 2010 10:07 AM
To: Thompson, John
Subject: RE: Execute({ object => '...' })

 

 

Can you use import => 1 to get all the subs into the current namespace
and just check there?

Embperl::Object adds some overhead so I was just trying to avoid that.
If thats not an issue then just go ahead and set up the %ENV entries
according to the Embperl::Object doco and you're good to proceed with
your $obj->can checks like you intended.

-----Original Message-----
From: Thompson, John [mailto:jthomp@midwestern.edu]
Sent: Wed 28/07/2010 02:42
To: Andrew O'Brien
Subject: RE: Execute({ object => '...' })

You are correct, I wasn't thinking when I set up that epl file. As far
as the Execute({ sub => '...' }) option, I have been using that, however
I wanted to avoid the overhead of grep'ing the file first to see if the
function even exists. I want to call it if it exists, and not if it
doesn't. I figured the fastest way was to have Embperl process it using
object, and then do "if($obj->can('head')) { $obj->head(); }". Is there
a better way? (Also realize, that Embperl will be processing the whole
template in a second, so I figured since it does caching, I'd have very
little performance penalty.)

-----Original Message-----
From: Andrew O'Brien [mailto:andrewo@oriel.com.au]
Sent: Monday, July 26, 2010 4:56 PM
To: Thompson, John; embperl@perl.apache.org
Subject: RE: Execute({ object => '...' })


> From: Thompson, John [mailto:jthomp@midwestern.edu]
> Sent: Tuesday, 27 July 2010 2:47 AM

Hi John,

> I am attempting to use the Execute({ object => '...' })
> feature but am seeing strange results. Here are my two files:

Firstly, test.epl does not do what you think it does. It should read:

[$ sub head $]
[- print "head\n"; -]
[$ endsub $]


Secondly, to use embperl files as objects I believe you need to be using
Embperl::Object which has additional configuration requirements. For
offline processing I would suggest that it may be overkill.

If all you want to do is execute a sub in another file then following
approaches both work with standard Embperl:

use Embperl;
Embperl::Execute( { inputfile => 'test.epl', sub => 'head' } );
Embperl::Execute( 'test.epl#head' );

Cheers,

Andrew

> - embperl1.pl -
>
> use Embperl;
>
> 
>
> my $obj = Embperl::Execute({ object => 'test.epl' });
>
> print "[$obj]\n";
>
> ---
>
> 
>
> - test.epl -
>
> [$ sub head $]
>
>     print "head\n";
>
> [$ endsub $]
>
> 
>
> print "main\n";
>
> ---
>
> 
>
> When I execute embperl1.pl I get:
>
> 
>
> % perl embperl1.pl
>
> [0]
>
> 
>
> Any ideas? I am on HP-UX itanium ia64, Embperl 2.3.0.  I
> decided to double check and make sure Embperl passed all
> tests when I built it, it did.
>
>


Mime
View raw message