On Thu, Feb 12, 2009 at 5:12 AM, Dave Howorth <[email protected]>wrote:
> Brian Sherwood wrote: > > Thank you all. A lot of good ideas, but so far no luck :( > > > > Simon recommended writing a plugin, or wrapping Net::IP using > > Template::Plugin::Class > > I tried using the Template::Plugin::Class, but it would throw an > exception. > > I used the following code: > > > > [% connector1 = '1.2.10.128/29 <http://1.2.10.128/29>' %] > > [% USE c1_net = Class ('Net::IP') %] > > > > [% c1.net.set(connector1) %] > > > > connector1 = [% c1_net.prefix %] > > > > returns > > > > Uncaught exception from user code: > > undef error - Can't use string ("Net::IP") as a HASH ref while > > "strict refs" in use at /usr/lib/perl5/vendor_perl/5.10.0/Net/IP.pm line > > 372. > > That's not surprising is it? > > line 372 is is_prefix, which needs an object as invoker and is invoked > on the invocant of prefix. But you've invoked prefix as a class method. > It is documented as an object method, so why did you expect it to work? > Hmm... Good point. As far as I know I have invoked it as a object method and not a class method. (Actually, I have no idea where it was invoked from and just assumed it was invoked from another object method) > > BTW, what is the variable c1 on the previous line? > typo. it should be c1_net. this changes the error to: Uncaught exception from user code: undef error - Can't use string ("Net::IP") as a HASH ref while "strict refs" in use at /usr/lib/perl5/vendor_perl/5.10.0/Net/IP.pm line 217. The problem is now in the set function when it tries to access what should be the blessed hash. Looks like same problem, different line. If I understand this right, it looks like somehow TT is not calling the object methods correctly. (or I am not specifying it correctly) [text deleted] >> >> As far as I can tell, the Net::IP class seems to work find for all >> methods, except the ip_add_num method that returns a reference to a new >> object. I assume the problem is something to do with the way the >> reference is stored or retrieved. > >I don't know Net::IP and I don't know enough about Perl semantics to >know whether it's significant so I'll just point out that ip_add_num() >is an undocumented private method that is intended to be called by the >overloaded '+' operator, and ask whether any gurus know if this is >significant? > >Cheers, Dave > Another good point. Since I can access it just fine from plain perl I was not too concerned about it being undocumented or private. (AFAIK it is not really a private function, just an undocumented one). Thanks Brian
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
