Example 5-3. examples/scalars/read_from_stdin.pl
#!/usr/bin/perl use strict; use warnings; print "Enter your name, please: "; my $name = <STDIN>; print "Hello $name, how are you ?\n";
STDIN - Standard Input (usually it is the keyboard)
Reading one line (till ENTER) from STDIN
$ perl examples/read_from_stdin.pl
Enter your name, please: Foo
Hello Foo
, how are you ?
There is this problem of the newline
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| Greeting with a name, Variable interpolation | Up | chomp |