Re: strange problem with STDIN- need help



Poonam Pahil wrote:
> Iam using <STDIN> to accept user input but the script just hangs at that
> point.
> I type in the value & program is just stuck at that point.
>
> i know its got to do with buffer flushing. when iam using the same piece of
> code at the beginning of the script everything works fine.
>
> iam using system() a lot. directing input/output to/from files. can this be
> the reason.

No.

Search your code for the $/ variable. I'm betting you changed it at
some point, without localizing the changes. Whereever you changed it,
enclose it's change and the subsequent read(s) in a block, and put the
word 'local' before the change:

{
local $/ = "\n\n";
my $paragraph = <STDIN>;
}

Read about what the $/ variable does in:
perldoc perlvar


> This is the piece of code:
>
> print "Do you want to remove this CSpec(y/n):";
> my $remove_CS = <STDIN>;
> chop($remove_CS);
> if($remove_CS =~ m/n/i )

Try running that piece of code on it's own, and you will see that
nothing there is the problem. The problem lies elsewhere in your code.

Paul Lalli

.



Relevant Pages

  • Re: merge in turn
    ... >>> If you're as good as you say IAM and RoaADA think you are how come ... were stuck with holier-than-thou joes who believe that just ... because they're brainless enough to sit in a queue rather than use ...
    (uk.rec.driving)
  • Re: Which function to use
    ... stuck on. ... As you can tell Iam a novice!! ...
    (microsoft.public.excel.misc)
  • strange problem with STDIN- need help
    ... Iam using to accept user input but the script just hangs at that ... I type in the value & program is just stuck at that point. ... code at the beginning of the script everything works fine. ...
    (perl.beginners)