Loading ...
Sorry, an error occurred while loading the content.

Re: help on autoincrement IP Adresses

Expand Messages
  • Brian Harnish
    ... $var3= 192.40.54.n+10 ... $var2 = 127.0.0.1 ; $var3 = ($var2 =~ /( d+ . d+ . d+ .)( d+)/)[0].($2+10); #$var3 now equals 127.0.0.10
    Message 1 of 2 , Nov 29, 2001
    • 0 Attachment
      --- In perl-beginner@y..., Jorge Goncalvez <goncal11@c...> wrote:
      > I wanted to print this in a file:
      >
      > subnet $var1 netmask 255.255.255.0{range dynamic-bootp $var2 $var3;
      > }
      >
      > $var1,$var2,$var3 are IP adress.
      > I do it and It works but now I wanted to do this:
      >
      > In fact I wanted for exemple:$var2="192.40.54.n" and
      $var3="192.40.54.n+10"
      > How can I do this in Perl

      The easiest way I can think of is:
      ----->8---- Cut ----8<-----
      $var2 = '127.0.0.1';
      $var3 = ($var2 =~ /(\d+\.\d+\.\d+\.)(\d+)/)[0].($2+10);
      #$var3 now equals '127.0.0.10'
      ----->8---- Cut ----8<-----
    Your message has been successfully submitted and would be delivered to recipients shortly.