http://qs321.pair.com?node_id=1165938

Ganesh Bharadwaj1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I have currently developed a perl file to convert Celsius to Fahrenheit. The code looks like this

#!/usr/local/bin/perl use Tk; my $mw = new MainWindow; # Main Window my $VARIABLE; my $frm_name = $mw -> Frame() -> pack(); my $lab = $frm_name -> Label(-text=>"Enter Celsius Value:") -> pack(); my $ent = $frm_name -> Entry(-textvariable=>\$VARIABLE) -> pack(); my $but = $mw -> Button(-text=>"Push Me", -command =>\&push_button) -> + pack(); #Text Area my $frm_name2 = $mw -> Frame() -> pack(); my $lab2 = $frm_name2 -> Label(-text=>"Farienhiet:") -> pack(); my $txt = $mw -> Text(-width=>40, -height=>10) -> pack(); MainLoop; #This function will be executed when the button is pushed sub push_button { $txt->delete("1.0", 'end'); my $celsius = $ent -> get(); my $farienhiet = ($celsius*9/5)+32; $txt -> insert('end', "Farienhiet is $farienhiet degrees."); }

I want the user to enter the number of values for which he wants to do Celsius to Fahrenheit. Assume he wants to convert 1 celcius value to fareinhiet, my code works. If he wants to convert 4 or 5 or 6, my code will not be able to do that. I want to let the user decide the number of values of celcius he wants to enter. Is this possible.

I was thinking of implementing a scale, like

my $scl = $mw -> Scale(-label=>"No of Celcius Values to convert :", -orient=>'v', -digit=>1, -from=>1, -to=>10, -variable=>\$celcius, -tickinterval=>2);

where the user can select any number of values from 1-10. If he selects 1, the grid can have one text location to enter and one text output, if he selects 2, then the grid will have 2 locations to enter text and 2 locations to show the fareinheit value and so on. Is this possible? Your help is greatly appreciated.