Hi Brian,

On 11/2/09 02:58, Brian Sherwood wrote:
> I am trying to use the Net::IP module within a template and seem to be 
> having some problems.
> I am setting LOAD_PERL and just loading the standard Perl Net::IP module.

I don't think this is a TT problem. The equivalent perl code doesn't 
work either:

#!/usr/bin/perl

use strict;
use warnings;
use Net::IP;

my $connector1 = '1.2.10.128/29';

my $c1_net = Net::IP->new( $connector1 );

print "connector1 = " . $c1_net->prefix . "\n";
print "connector1 = " . $c1_net->ip . ' ' . $c1_net->mask . "\n";

my $c2_net = $c1_net->ip_add_num( 2 );

print "connector2 = " . $c2_net->prefix . "\n";


#####################

Gives the output:

connector1 = 1.2.10.128/29
connector1 = 1.2.10.128 255.255.255.248
Use of uninitialized value in concatenation (.) or string at netip.pl 
line 16.
connector2 =

######################


I'm not familiar with this module but it doesn't appear to implement an 
ip_add_num method. No wait, it's the internal method for overloading +.

It looks like some sort of bug in Net::IP but once you get the perl 
version working you should be able to translate that into TT syntax.

This obviously highlights one reason for not doing that as it's harder 
to write your tests to target the templates than it is to write tests 
for perl code using the great test tools that are available from the CPAN.

Best of luck.

Simon.

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to