Hi, what is the best way to find out the depth of the last word within a line? "Depth of a word" means "how many other words occur before the last one?".
The background is that I want to write a CLI. The CLI shall know a number of commands like 'show', 'set', 'alias' and so on. Using Term::ReadLine, I want to have completion. Since commands on a line will need to occur in a particular order, I want to make it so that the completion shows what can occur next depending on what is already on the line. For example, when the line is 'show', the completion must not display 'show' as it would when the line is still empty, but 'settings tables levels'. To accomplish this, I figured I need to attribute every command with a depth --- like 'show' and 'alias' have a depth of 0 and 'settings', 'tables', and 'levels' have a depth of 1. I´m aware that this only works for a rather simple CLI that doesn´t have too many commands. Maybe there is a better solution --- if you ever configured a switch or a router that has a good CLI, you know what I´m trying to do. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/