You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Hartmaier Alexander <Al...@t-systems.at> on 2004/12/27 20:01:47 UTC
strange object oriented problem...
Hi list!
I started to use object oriented coding in (emb)perl on the 23rd ;-)
I just discovered a strange behaviour...
I define an array of object method names...
[-
@colname = ( "name", "fk_device", "snmpid", "snmpid_rtt", "type",
"speed", "mtu", "ipaddr", "ipnetmask", "description");
-]
A couple plain html lines later I have
[$ foreach $col ( @colname ) $]
[$ if ($obj_int_nac->$col ne $obj_int_scan->$col) $]
<tr class="light">
<td class="dark">[+ $col +]</td>
<td>[+ $obj_int_nac->$col +]</td>
<td>[+ $obj_int_scan->$col +]</td>
</tr>
[$ endif $]
[$ endforeach $]
This workaround code works:
[$ foreach $col ( @colname ) $]
[-
$col_name = $col;
$nac = $obj_int_nac->$col;
$scan = $obj_int_scan->$col;
-]
[$ if ($nac ne $scan) $]
<tr class="light">
<td class="dark">[+ $col_name +]</td>
<td>[+ $nac +]</td>
<td>[+ $scan +]</td>
</tr>
[$ endif $]
[$ endforeach $]
The variable $col gets overwritten after the '[$ if ($obj_int_nac->$col
ne $obj_int_scan->$col) $]' by a counter starting with '0'.
The result is an error that the method '0' is unknown for the object
'$obj_int_nac'...
Any ideas?
With kind regards
Alexander Hartmaier
T-Systems Austria GesmbH
Rennweg 97-99 1030 Wien
phone: +43 57057-4320
fax: +43 57057-95-4320
mobile: +43 676 8642 4320
mail: alexander.hartmaier@t-systems.at
internet: http://www.t-systems.at <http://www.t-systems.at/>
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Hinweis: Dieses E-mail kann vertrauliche und gesch�tzte Informationen enthalten.
Sollten Sie nicht der beabsichtigte Empf�nger sein, verst�ndigen Sie bitte den Absender und l�schen Sie dieses E-mail dann sofort.
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*