Thank y'all, I got to where I want to be: https://github.com/ag4ve/geocidr
On Sun, May 26, 2013 at 8:06 AM, Michael Rasmussen <mich...@jamhome.us> wrote: > On Fri, May 24, 2013 at 03:18:35PM -0400, shawn wilson wrote: >> How do I find the next subnet? This should print 192.168.1.0 the >> second time - it errors: > > [code deleted] > Why should it? The Net::IP documentation doesn't provide any information about > actions that cross the subnet boundry. > > Having said that, it seems it doesn't allow that operation. > And in fact, many of the methods don't work after incrementing, which seems > wrong to me: > > #!/usr/bin/perl > use strict; > use warnings; > use Net::IP; > > my @method_types = qw ( ip short binip intip mask last_ip prefixlen size > iptype reverse_ip ); > > my $ip = Net::IP->new('192.168.0.0/24'); # three lines from your code > print "Start ip [" . $ip->ip . "]\n"; > print "start mask [" . $ip->prefixlen . "]\n"; > > $ip++; > print "After incrementing by 1\n"; > show_methods($ip); > > $ip->set($ip->last_ip) ; > $ip++ ; > print "\nAfter incrementing past last_ip\n"; > show_methods($ip); > > > sub show_methods { > my ($ip) = @_; > > print "now at " . $ip->ip ,$/; > > for my $type ( @method_types) { > if( $ip->$type ) { > print "$type : ", $ip->$type(), $/; > } > else { > print "no more $type\n"; > } > } > } > > > __END__ > > michael@bivy:~/rmme$ ./tpl > Start ip [192.168.0.0] > start mask [24] > After incrementing by 1 > now at 192.168.0.1 > ip : 192.168.0.1 > short : 192 > binip : 11000000101010000000000000000001 > intip : 3232235521 > no more mask > last_ip : 192.168.0.255 > no more prefixlen > size : 255 > iptype : PRIVATE > no more reverse_ip > > After incrementing past last_ip > Can't call method "ip" on an undefined value at ./tpl line 29. > michael@bivy:~/rmme$ > > > > > -- > Michael Rasmussen, Portland Oregon > Be Appropriate && Follow Your Curiosity > Other Adventures: http://www.jamhome.us/ or http://gplus.to/MichaelRpdx > A special random fortune cookie fortune: > Only the mediocre are always at their best. > ~ Jean Giraudoux, French Novelist > (rephrased as "Only the mediorcre are at their best all the time." > ~ G.M. Ford in "Who the hell is Wanda Fuca?") -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/