in reply to STDIN behaves different according to context

When I'm trying to use <STDIN> in scalar context my scripts are executed without me being able to give an input
It sounds like something is already waiting on STDIN when you read from it. So when you read from STDIN in a scalar context it will read whatever's waiting but in list context it will continue reading until it receives an EOF. Further information about your system and perl version would go a great way towards finding a solution.
HTH

_________
broquaint

  • Comment on Re: STDIN behaves different according to context

Replies are listed 'Best First'.
Re: Re: STDIN behaves different according to context
by hardburn (Abbot) on Feb 17, 2003 at 15:00 UTC

    In such a case, it might be useful to figure out what exactly is coming into STDIN without your knowing about it. Try converting each character to its numeric value and write that:

    my $a = <>; local $, = ' '; # Put some whitesapce between each number print unpack("U*", $a), "\n";

    Above is untested, as always.

    ----
    Invent a rounder wheel.

Re^2: STDIN behaves different according to context
by LAI (Hermit) on Feb 17, 2003 at 13:52 UTC

    Also, it would be useful to know how the script is being called. If you're running it by calling (dumb example):

    $ echo '' | myscript.pl

    then I can see the problem.

    LAI
    :eof

Re: Re: STDIN behaves different according to context
by Anonymous Monk on Feb 18, 2003 at 07:52 UTC
    I figured out what is waiting in STDIN, it is a "new line feed or a new line", the numeric value 10. What system and version am I using? I'm using the perl version 5.6.1 for MSWin32-x86-multi-thread. I'm runing my programs with CYGWIN, a Unix environment for Windows.