{##### block of code ##### my $button2 = $frame2->Button(-text => "Label", -command => \&subroutine2($label2, $frame2, $button1, $button2))->pack(); ##### block of code ends here ##### } sub subroutine2{ foreach @_{ packForget $_; } ##### rest of subroutine ##### }