#! /usr/bin/perl -w use Tk; $mw=MainWindow->new(); @type_of_processing=("type1","type2","type1","type1","type2"); $step_no=0; foreach(@type_of_processing) { $step_no++; if($_ eq "type1") { type1_settings(); } elsif($_ eq "type2") { type2_settings(); } } MainLoop; sub type1_settings { $label{$step_no}=$mw->Label(-text=>"This is processing step no. $step_no. (type1)")->pack; $entry{$step_no}=$mw->Entry(-width=>20,-state=>'disabled')->pack; $checkbutton{$step_no}=$mw->Checkbutton ( -text=>"export results to: ", -variable=>\$status, -command=>sub { if($status==1) { $entry{$step_no}->configure(-state=>'normal') } else { $entry{$step_no}->configure(-state=>'disabled') } } )->pack(-before=>$entry{$step_no}); } sub type2_settings { $label{$step_no}=$mw->Label(-text=>"This is processing step no. $step_no. (type2)")->pack; $entry{$step_no}=$mw->Entry(-width=>20,-state=>'disabled')->pack; $checkbutton{$step_no}=$mw->Checkbutton ( -text=>"export results to: ", -variable=>\$status, -command=>sub { if($status==1) { $entry{$step_no}->configure(-state=>'normal') } else { $entry{$step_no}->configure(-state=>'disabled') } } )->pack(-before=>$entry{$step_no}); }