in reply to Read two values from input
The code is not with error, it just doesn't work the way you want. Two reasons:
1) <STDIN> reads a complete line until you hit the carriage return key.
2) The line read in by <STDIN> still has that carriage return character at the end
So instead of reading two lines you obviously want to read one line and then separate the two values:
$line=<STDIN>; chomp $line; # this removes the CR character at line end ($a,$b)= split / +/, $line; #splits the line wherever it finds spaces
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read two values from input
by ikegami (Patriarch) on Nov 25, 2011 at 00:43 UTC | |
|
Re^2: Read two values from input
by Marshall (Canon) on Nov 27, 2011 at 12:18 UTC | |
by Anonymous Monk on Nov 27, 2011 at 12:24 UTC | |
|
Re^2: Read two values from input
by knils_r00t (Novice) on Nov 29, 2011 at 10:14 UTC |