sub f_mode { my $ref = shift; my $name = shift; #For each key value check the value of radio button value while ( my ($name, $value) = each(%f_switch_val) ) { #If "Manual" button is clicked, then do the following if ($f_switch_val{$name} eq "man"){ # Do this } #If "Auto" button is clicked, then do the following elsif ($f_switch_val{$name} eq "auto"){ #Do this } } }