As AM points out above, in a very nice article I might add, you've linked to a tutorial whose Perl code is for Tkx. Here's a Tk version:
use Tk;
use Scalar::Util qw{looks_like_number};
my ($feet, $metres) = (q{}, q{});
my $mw = MainWindow->new(-title => q{Feet to Metres});
my $f = $mw->Frame()
->grid(-padx => 12, -pady => 3, -sticky => q{nsew});
my %pad = (-padx => 5, -pady => 5);
my $feet_E = $f->Entry(-textvariable => \$feet, -width => 7)
->grid(-row => 0, -column => 1, -sticky => q{we}, %pad);
$f->Label(-text => q{feet})
->grid(-row => 0, -column => 2, -sticky => q{w}, %pad);
$f->Label(-text => q{is equivalent to})
->grid(-row => 1, -column => 0, -sticky => q{e}, %pad);
$f->Label(-textvariable => \$metres)
->grid(-row => 1, -column => 1, -sticky => q{we}, %pad);
$f->Label(-text => q{metres})
->grid(-row => 1, -column => 2, -sticky => q{w}, %pad);
my $calc_B = $f->Button(-text => q{Calculate}, -command => sub {
$metres = looks_like_number($feet)
? int(0.3048 * $feet * 10000.0 + 0.5) / 10000.0 : q{};
})->grid(-row => 2, -column => 2, -sticky => q{w}, %pad);
$feet_E->focus();
$mw->bind(q{<Return>} => sub {$calc_B->invoke()});
MainLoop;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.