perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gavin Spomer <spom...@cwu.EDU>
Subject Object Arrays & Dynamic Tables
Date Tue, 05 Jun 2007 20:30:26 GMT
Hi Folks,

I have an array of "facet" objects called @facets. A "facet" object has a method called facet_name.
I would like to output this using dynamic tables, instead of having to do an Embperl foreach
loop. The following Embperl foreach loop works:

   <table>
   [$ foreach $facet (@facets) $]
      <tr>
         <td>[+ $facet->facet_name +]</td>
      </tr>
   [$ endforeach $]
   </table>

However when I try using an Embperl dynamic table (as desired) like the following:

   <table>
      <tr>
         <td>[+ $facets[$row]->facet_name +]</td>
      </tr>
   </table>

I get an error:

   [1381]ERR: 24: Error in Perl code: Can't call method "facet_name" on an undefined value
at /usr/local/mylibrary/index.epl line 17.

Oddly enough, the following works (using a literal value of zero instead of $row):

   <table>
      <tr>
         <td>[+ $facets[0]->facet_name +]</td>
      </tr>
   </table>

And also this works too, even though it isn't the output I'm looking for: (It's not calling
facet_name)

   <table>
      <tr>
         <td>[+ $facets[$row] +]</td>
      </tr>
   </table>

What am I doing wrong? It seems to me like something funky is going on with $row.

Gavin Spomer
Systems Programmer
Brooks Library
Central Washington University

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message