Re: Next subnet

2013-05-25 Thread Dr.Ruud

On 24/05/2013 21:18, shawn wilson wrote:


How do I find the next subnet? This should print 192.168.1.0 the
second time - it errors:
#!/usr/bin/env perl

use strict;
use warnings;

use Net::IP;

my $ip = Net::IP-new('192.168.0.0/24');

print Start ip [ . $ip-ip . ]\n;
print start mask [ . $ip-prefixlen . ]\n;

$ip-set($ip-last_ip);
$ip++;
$ip-set($ip-ip . / . $ip-prefixlen);

print Start ip [ . $ip-ip . ]\n;
print start mask [ . $ip-prefixlen . ]\n;


Or without Net::IP:

perl -Mstrict -wle'
  my $subnet = $ARGV[0];

  my ($ip, $bits) = $subnet =~ m{(\S+)/(\S+)};  # parse

  my $ip_int = unpack N, pack , split /\./, $ip;
  my $step = 1  (32 - $bits);

  #$ip_int = (0x ^ ($step - 1));  # normalize
  $ip_int += $step;  # increment

  my $next_ip = sprintf %vd, pack N, $ip_int;
  print $next_ip/$bits;
' 192.168.0.42/24

192.168.1.42/24

(you can activate the normalization if wanted)

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Scripts in Padre do not run. Need step-by-step help in setting up, asall current procedures I have found have failed for me.

2013-05-25 Thread Dr.Ruud

On 24/05/2013 22:25, Michael Goldsbie wrote:


[...] I installed DWIM Perl  [...]
So after downloading and installing it, what's the next step?


On http://dwimperl.com/ there is a link to 'Perl Tutorial',
which has a link to 'Introduction 1. Install'.

It mentions:

Go ahead, download the exe file and install it on your system. Before 
doing so, please make sure you don't have any other Perl installed.


Try 'which perl' on the command prompt. What does it report?

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/