package MyApp::Widgets; ... sub Button { my ($parent, $text, $callback, %options) = @_; if (ref $text) { $options{-textvariable} = $text } else { $options{-text} = $text } if (ref($callback) ....) { $options{-command} = $callback; } else { $options{-background} = '#ff0000'; } # else return $parent->Button( -font => $StdButtonFont, -background => '#ffdd00', %options, ); } # Button