my @routines = ( \&routine0, \&routine1, ); $routines[$input]->($input = <>); sub routine0 { print "0"; } sub routine1 { print "1"; }