my %nodes = ( 'page1' => \&home, 'something' => \&something, 'another' => \&another ); ##later on... ##stolen from The Perl Cookbook ##assuming that page wanted is in $current_screen while(my ($wanted_screen, $function) = each %nodes) { $function->($wanted_screen eq $current_screen); } sub page1($) { my $active = shift; ##do stuff here based on whether its active or not } ##declare other subs here, taking a true or false value as an arg as shown above