abubacker has asked for the wisdom of the Perl Monks concerning the following question:

I want to implement a command line features in the linux terminal as similar to ftp command.
I have used Term::Readline module , it works fine , but when I press tab it displays the files in the current directory , but I wanted my own commands to be displayed
Please help me how to do this using this module itself or referring some other module is also fine

For example :

use Term::ReadLine; my $term = Term::ReadLine->new('Simple Perl calc'); my $prompt = "Enter your arithmetic expression: "; my $OUT = $term->OUT || \*STDOUT; $term->MinLine(1); while ( defined ($_ = $term->readline($prompt)) ) { my $res = eval($_); warn $@ if $@; print $OUT $res, "\n" unless $@; $term->addhistory($_) if /\S/; #print Dumper $term->findConsole(); #print Dumper $term->Attribs(); print Dumper $term->Features(); print Dumper $term->tkRunning(); print Dumper $term->ornaments(1); }
Thanks in advance !

Replies are listed 'Best First'.
Re: Implementing a command line
by Anonymous Monk on Mar 17, 2010 at 06:15 UTC

      Thanks for your reply
      Before that I used Term::shellUI module and almost every thing is working as expected but the issue is when I pressed ctrl+c I want to print "Please use ctrl+d to exit the shell" , for that I handle the signal but the message print only after I pressed the new line
      how to resolve this !
      once again thanks in advance !