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
In reply to Problems with <STDIN> in scalar context by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |