Menu

Commands executed in the wrong order?

Help
2005-11-17
2013-05-20
  • Christoph Wiest

    Christoph Wiest - 2005-11-17

    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?

     
    • Jan Ploski

      Jan Ploski - 2005-11-17

      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.

       
    • Christoph Wiest

      Christoph Wiest - 2005-11-18

      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?

       
      • Jan Ploski

        Jan Ploski - 2005-11-18

        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.

         
    • Christoph Wiest

      Christoph Wiest - 2005-11-21

      Thank you again for helping a newbie :-)

       

Log in to post a comment.