in reply to Re: How to enter a MAC address
in thread How to enter a MAC address
This is what I had. I'm pretty new to this stuff, learning perl and tk as I go.
use strict; use Tk; # Take a 6 element array and make it string. sub makeString { my @data = @_; my $result = sprintf "%02x:%02x:%02x:%02x:%02x:%02x", $data[0], $data[1], $data[2], $data[3], $data[4], $data +[5]; return $result; } sub doit { my @addy = @_; my $mw = MainWindow->new(); # Show the current address my $current = makeString(@addy); $mw->Label(-text => $current)->pack(-side => 'top'); # now build some entry widgets to change it for (my $i = 0; $i < 6; $i++) { $mw->Entry(-textvariable => \$addy[$i], -width => 3) ->pack(-side => 'left'); $mw->Label(-text => ':', -width => 1)->pack(-side => 'left'); } $mw->Button(-text => "Done", -command => sub {$mw->destroy;}) ->pack(-side => 'bottom'); MainLoop; return(@addy); } my @foo = (0x10, 0x22, 0x33, 0x4b, 0x5f, 0x6d); print "Starting with: " . makeString(@foo) . "\n"; my @bar = doit(@foo); print "Ended with: " . makeString(@bar) . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to enter a MAC address
by liverpole (Monsignor) on Feb 14, 2007 at 22:28 UTC | |
by snotnose (Novice) on Feb 15, 2007 at 00:00 UTC | |
by liverpole (Monsignor) on Feb 15, 2007 at 00:14 UTC |