Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm having problems when using <STDIN> in scalar context. Example: when runing the script below the whole script is executed without stoping to recive input. $some_string is automatically set to "". The problem dosen't occure if the <STDIN> is called in scalar context in a while loop, or if <STDIN> is called in list context. What's wrong? I'm greatfull for all suggestions!
Thanks!%map = qw(red apple green leaves blue ocean); print "A string please: "; chomp($some_string = <STDIN>); print "The value for $some_string is $map{$some_string}\n";
update (broquaint): fixed ending <code> tag
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with <STDIN> in scalar context
by VSarkiss (Monsignor) on Feb 17, 2003 at 18:18 UTC | |
|
Re: Problems with <STDIN> in scalar context
by jasonk (Parson) on Feb 17, 2003 at 18:06 UTC |