Hi! I'm new to eclipse and encountering a strange phenomenon:
I'm using Eclipse 3.1.1 with EPIC 0.3.0, Active Perl 5.8.7.813 on Windows XP.
When I run a perl-script within eclipse (via Run -> Perl Local, without CL-parameters), the commands (or lines of code?) are executed in the wrong order.
As an example some simple lines of code:
print "\nPlease enter string:\n";
$string = <STDIN>;
print "$string\n";
The output in the perl-console doesnt't print the text at first, but waits for the <STDIN>. After entering a string, the first print-command is displayed, and in the next line the entered string:
string-text
Please enter string:
string-text
If I start the same script using the windows command line (e.g. "perl test.pl"), the script is excuted properly.
Do you have any suggestions about this phenomenon?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The first line appears on the screen later because of the STDOUT buffering - this is not strictly EPIC-related and does not mean that statements are executed in a different order.
Read about the special variable $| on the perlvar manual page. If you set it to 1 at the beginning of your script, it will behave the same in terminal mode and EPIC.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi! I'm new to eclipse and encountering a strange phenomenon:
I'm using Eclipse 3.1.1 with EPIC 0.3.0, Active Perl 5.8.7.813 on Windows XP.
When I run a perl-script within eclipse (via Run -> Perl Local, without CL-parameters), the commands (or lines of code?) are executed in the wrong order.
As an example some simple lines of code:
print "\nPlease enter string:\n";
$string = <STDIN>;
print "$string\n";
The output in the perl-console doesnt't print the text at first, but waits for the <STDIN>. After entering a string, the first print-command is displayed, and in the next line the entered string:
string-text
Please enter string:
string-text
If I start the same script using the windows command line (e.g. "perl test.pl"), the script is excuted properly.
Do you have any suggestions about this phenomenon?
The first line appears on the screen later because of the STDOUT buffering - this is not strictly EPIC-related and does not mean that statements are executed in a different order.
Read about the special variable $| on the perlvar manual page. If you set it to 1 at the beginning of your script, it will behave the same in terminal mode and EPIC.
Thank You very much for this hint!
What I still don't understand: Why isn't Windows witch Active Perl affected by this flushing-methode?
man perlvar says
"STDOUT will typically be line buffered if output is to the terminal and block buffered otherwise."
So it seems that perl.exe run by means of Java's Runtime.exec(...) can somehow detect that it is not run from terminal.
Thank you again for helping a newbie :-)