> It will return for the given example '2001:db8:123/44' which as I
> understands is the correct meaning of '2001:db8:123' when we split
> at nibble endings.

Oh, well, it isn't. It should be expanded to 2001:db8:1230::/24.

Add the four marked lines:

  # Get the length of the last segment
  my $lastseglen = length( (split(/:/,$ip))[$cntcolons] );
  
+  # Attach trailing zeros to last segment if needed
+  $ip .= '0' x ( 4-$lastseglen );

+  # Attach :: at the end if address is less than 8 blocks
+  $ip .= '::' if ( $cntcolons < 7 );
  
  # And now calculate the number of significant bits and append
  $ip .= '/' . ( $cntcolons*16 + $lastseglen*4 );



Regards,
Michael

-- 
It's an insane world, but i'm proud to be a part of it. -- Bill Hicks

Reply via email to