Tk::IPEntry - A megawidget for input of IP-Adresses IPv4 and IPv6
use Tk; use Tk::IPEntry; my $mw = MainWindow->new(); my $ipadress; my $entry = $mw->IPEntry( -variable => \$ipadress, )->pack(-side => 'left'); $ipadress = '184.108.40.206'; MainLoop;
The format of Ip-Number.
Here come the methods that you can use with this Widget.
Specifies the name of a variable. The value of the variable is a text string to be displayed inside the widget; if the variable value changes then the widget will automatically update itself to reflect the new value. The way in which the string is displayed in the widget depends on the particular widget and may be determined by other options, such as anchor or justify.
Set the IP number to display. You can use all standart format for IP-Adresses in Version 4 and Version 6. Here comes some examples, please look also in perldoc from Net::IP:
A Net::IP object can be created from a single IP address: $ip->set('220.127.116.11') || die ... Or from a Classless Prefix (a /24 prefix is equivalent to a C class): $ip->set('195.114.80/24') || die ... Or from a range of addresses: $ip->set('18.104.22.168 - 22.214.171.124') || die ... Or from a address plus a number: $ip->set('126.96.36.199 + 255') || die ... The set() function accepts IPv4 and IPv6 addresses (it's necessary set -type option to 'ipv6'): $ip->set('dead:beef::/32') || die ...
Very interesting feature, you can give Ip-Ranges and the user can only choice a Ip-Adress in this Range. The other Numbers is disabled. I.E.:
$ip->set('195.114.80/24') || die ... $ip->set('dead:beef::/32') || die ...
Here you can get IP number from display. This is also a Interface to Net::IP, in example you will get the binary code from displayed IP-Number then you can call:
Please look for all allow commands to Net::IP.
This prints the last error.
Please see for examples in 'demos' directory in this distribution.