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

Hi perl monks, I need to create a command window like cmd.exe using perl Tk. I am using Term::ShellUI, but the problem is it doesnt create a new window but continues the operation in the existing command window. I even tried issuing a system(start); but of no use.
use Term::ShellUI; system(start); my $term = new Term::ShellUI( commands => { "quit" => { desc => "Quit this program", maxargs => 0, method => sub { shift->exit_requested(1); }, }}, ); $term -> prompt("My Prompt>"); $term->run();
Please help me in creating a new command window with the prompt set to "My Prompt>" and executes only the commands that are defined in command block.

Replies are listed 'Best First'.
Re: Create new command winow using Term::ShellUI
by Anonymous Monk on Jun 03, 2008 at 12:35 UTC
    Like this
    unless( @ARGV ){ # open new shell and restart program my $cmd = join ' ', q(cmd.exe /c start ), $^X,__FILE__, '1forargv'; +; system $cmd; exit; } ... $term->run();

      To include our friends with US installations of Microsoft Windows, always quote $^X:

      my $cmd = join ' ', q(cmd.exe /c start ), qq{"$^X"},__FILE__, '1forarg +v';

      Otherwise, the string interpolation will run afoul of Program Files :-)

        Hi, Thanks for the information. I was able to create a new Command window. can you please explain me about the use of '1forarg'. Since if i try to pass any arguments from the commnad it doesnt takes but gives me '1forarg' as an argument. Thanks in advance.