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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
my $confirmed = 0;
while (! $confirmed) {
printf("Please type the name of this application ( Format: Application_Name-Version ): ");
$app_name = <STDIN>;
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 = <STDIN>;
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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.
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 = <STDIN>;
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 = <STDIN>;
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
I have figured it out, using autoflush to flush the output.
Thanks for all the help.