Hi Monks,

the folowing code snippet is used in one of my applications
and - of course - it works, but - of course - could be better.
The main problem I have with this, is complete lack of editing
functionality not even mentioning gimmicks like expansion or
reverse-search etc. (all nice thingies I´m used from the bash):

CMD: while($exit eq FALSE) { # We´re as long in the lo +op until no exitflag print "> "; $line = <STDIN>; # read input from stdin chop $line; goto CMD if(!$line); # chop CR and if input wa +s empty.. REDO ($key,@param) = split ' ', $line; # split key and parameter +s $exit = &cmd_select($key,@param); }
cmd_select is just a huge if ... elsif function.

Now if I happen (and that happens often) to type in something
wrong, I have noch chance of editing it. Instead of Backspace
theres a ^H, instead of "Cursor-Up" theres some ^[OA and so
on.

How - o how my brothers can I get a decent CLI?
Obligatory question: Is there a module? :-)

Ciao


In reply to crafting a decent CLI by PetaMem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.