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

I've had this problem before with Open Perl IDE, but thougth that it's his fault. Actually I've never done much of desktop programming with Perl - mostly web stuff so I didn't cared much about it. Now I tried Eclipse & EPIC, and got same thing ...

When I have something like :

print "Test"; my $value = <STDIN>;
Instead of printing Test and waiting for input as expected - it waits for input, and once you enter something Test is printed. If you have more <STDIN> (like print, STDIN, print, STDIN) you need to enter all of those, and only then something is printed out ..

Anyone knows what's going on?

I also tried that in Komodo 3.1 and it works as expected ... (OT) BTW. Shure Komodo still needs few more things - but other than that it's great ...

Replies are listed 'Best First'.
Re: Problem with Perl editors.
by Corion (Patriarch) on Jul 05, 2005 at 15:03 UTC

    It's not them, it's you. You are Suffering from Buffering.

    In short, the following code near the top of your script will likely solve your problem:

    use strict; $|++;
      I would suggest $|=1; instead, just because it's a good habit. I've seen moronic situations where $| gets set to -1 (by a previous mistake by another coder) and thus the $|++ I put in place didn't exactly have the desired effect. ;-)

      Much better, IMO, to explicitly say what you mean.

      Larry Wall is Yoda: there is no try{}
      The Code that can be seen is not the true Code

        Are you sure?

        perl -e "$| = -1; print $|"

        $| is magical in that it can only have the values 1 and 0. $|++ switches unbuffering on, while $|-- toggles from on to off and back to on.

        I've seen moronic situations where $| gets set to -1
        Huh?!? I would be curious to know how to do so, since AFAIK it is not actually possible:
        $ perl -le 'print $|=-1' 1
      Right buffering ... havent tougth of that :)

      Then it's strange why it's working in Komodo as espected ...