Interactive input when running perl in Eclips

jli023 wrote on Tue Sep  2 05:11:50 MEST 2008:
I have a perl script, which accept user input during running. It works fine
when executing it in CMD window. But I would like to run it in Eclipse.


Do you know how to do the interactive input when running perl script in
Eclipse?

Thanks in advance. 

Jing
jploski wrote on Tue Sep  2 08:16:33 MEST 2008:
If you read from STDIN, it will work normally in Eclipse, just type your
input in the Console view. If you use a module which talks to a pseudoterminal,
then it won't work.
jli023 wrote on Wed Sep  3 00:29:42 MEST 2008:
Hello, 

Thank you very much for your reply. 

The scripts are:

my $confirmed = 0;
while (! $confirmed) {	
	printf("Please type the name of this application ( Format: Application_Name-Version
): ");
	$app_name = ;
	chop $app_name;
	
	$app_name =~ m/(^[^-]*)-(.*$)/;
	if ($1 && $2) {
		print("\nName: [$1]\tVersion: [$2]\n\n");
	} else {
		print("\nMust be in the Format: Application_Name-Version\n\n");
		next;
	}	
	
	my $valid = 0;
	while (! $valid) {	
		printf("Will create folder named [$app_name], is this correct?(yes/no):
");
		my $input = ;
		chop $input;
		if ( $input =~ m/^(y|Y)(e|E)(s|S)$/ ) {
			$valid = 1;
			$confirmed = 1;
		} elsif ( $input =~ m/^(n|N)(o|O)$/ ) {
			$valid = 1;
		}
	}
}

When executing it in cmd window, the printf and stdin codes are executed
in aright sequence. The results shown in the console window are:

Please type the name of this application ( Format: Application_Name-Version
): ant-1.0.0

Name: [ant]     Version: [1.0.0]

Will create folder named [ant-1.0.0], is this correct?(yes/no): yes
The syntax of the command is incorrect.


When running it in Eclipse, first the console does not show anything, after
I typed two lines input, the console displays the results of the printf
codes:

ant-1.0.0
yes
Please type the name of this application ( Format: Application_Name-Version
): 
Name: [ant]	Version: [1.0.0]

Will create folder named [ant-1.0.0], is this correct?(yes/no):

It seems that the printf and STDIN are not processed in a sequence in Eclipse.


Do you know there is  a command can force the printf to be processed before
the STDIN?

Thank you very much, 

Jing

jli023 wrote on Wed Sep  3 01:38:19 MEST 2008:
I have figured it out, using autoflush to flush the output. 

Thanks for all the help. 

Note: The above is an archived snapshot of a forum thread. Use the original thread at sf.net to post comments.