use Try::Tiny; while (my @parsed = &parseInput) { &dispatch(@parsed); } sub parseInput { my $inp = <>; chomp $inp; my @parsed = split $inp; return () if $parsed[0] eq `q`; return @parsed; } sub dispatch { my $cmd = shift; try { eval( '&' . $cmd . '(' . join ',', @_ . ');' ); } catch { print STDERR "Unrecognised command $cmd\n"; } # the above is a non-GUI example which would need adaptation } # and add a sub xxx for each command xxx