[Zope-Perl] question regarding perl based methods and dtml

Joseph Wayne Norton norton@arseed.co.jp
Mon, 21 Aug 2000 16:42:10 +0900 (JST)


Gisle -

I am experimenting with a few simple ways to integrate perl methods
within a dtml document.  I have 2 perl based methods, m_pl and
grep_pl, that are simply wrappers around the perl functions m and
grep.

I am facing trouble when passing a list object to the grep_pl method.
I'm not sure how to call the objectIds method first and then have a
list object passed as the argument 'list' to grep_pl method. Secondly,
are there any restrictions on having a list as a return value?

Any ideas?

thanks,

- j


I have a dtml document , 'test_dtml',  as follows:

        <dtml-var standard_html_header>
        <h2><dtml-var title_or_id></h2>
        <p>
          <dtml-with "PARENTS[0]">
        
          <p> <b> ObjectIds </b> </p>
          <dtml-in objectIds>
             <dtml-var sequence-item> <br>
          </dtml-in>
        
          <p> <b> ObjectIds w/ m </b> </p>
          <dtml-in objectIds>
             <dtml-if "m_pl('/test/', _['sequence-item'])">
               <dtml-var sequence-item> <br>
             </dtml-if>
          </dtml-in>
        
          <p> <b> ObjectIds w/ grep </b> </p>
          <dtml-in "grep_pl('/test/', objectIds())">
             <dtml-var sequence-item> <br>
          </dtml-in>
        
          </dtml-with>
        </p>
        <dtml-var standard_html_footer>

and the method "m_pl" with arguments "pattern, expr"

        my $ret;
        
        eval "\$ret = (\$expr =~ $pattern)";
        die "$pattern, $expr: $@" if ($@);
        
        $ret;

and finally the method "grep_pl" with arguments "expr, list":

        my @ret;
        
        eval "\@ret = grep $expr, \@{$list}";
        die "$expr, $list: $@" if ($@);
        
        @ret;
        
-- 

___________A_R_S_e_e_D__I_n_c_.__________
Joseph Norton
     C.T.O. (Chief Technology Officer)
              Tel:03-5431-5240 (Fax:5241)
Visit us! http://www.arseed.co.jp/garden/