Some suggestions:
- Indent your code properly. See perlstyle.
- Give your variables meaningful names. Extremely short variable names are "false economy".
- Perl understands real boolean values; use them. This lets you say if ( $sto ) rather than if ( $sto = 's' ).
- Learn to use arrays and hashes.
- Learn to use loops and subroutines for code re-use, rather than copy-and-paste.
- Don't set the width of the buttons. Or if you must, set them to something that allows the strings to be visible. A width of 1 makes a lot of your buttons unreadable. (Also, since width and height are numeric parameters, don't quote them.)
As an example of looping for code re-use, I rewrote part of your code into the following:
my %button_label =
(
Sum => '+',
Subtra => '-',
Multi => 'x',
Divi => '/',
Rs => 'R/S',
);
my %placement =
(
Enter => [ 197, 155 ],
Sum => [ 353, 170 ],
Subtra => [ 353, 140 ],
Multi => [ 353, 110 ],
Divi => [ 353, 80 ],
CLx => [ 150, 140 ],
XsY => [ 117, 140 ],
Rs => [ 83, 140 ],
SST => [ 50, 140 ],
RbS => [ 17, 140 ],
RCL => [ 150, 170 ],
STO => [ 117, 170 ],
OFF => [ 17, 170 ],
);
for (qw(
Enter Sum Subtra Multi Divi
CLx XsY Rs SST RbS RCL STO OFF
))
{
my $w = $mw->Button( -text => $button_label{$_} || $_, )->pack;
$w->place( -x => $placement{$_}[0], -y => $placement{$_}[1] );
}
We're building the house of the future together.