In Perl programming, we can get input from standard console using <STDIN>. It stands for Standard Input. It can be abbreviated by <>. So,
my $name = ;
is equivalent to:
my $name = <>;
Let's see an example where we are getting data from the user using Standard Input <STDIN>.
Type in:
use 5.010; use strict; use warnings; say "Enter your Name:"; my $name =; say "Welcome $name at rookienerd.";
Here, $name is a scalar variable. Variables are declared using my keyword. After running this script, it will ask for your name. Type your name in the console and press ENTER.
As you can see in the above output, a new line is added after printing the name. To overcome this problem, add the chomp function with $name as shown below.
use 5.010; use strict; use warnings; say "Enter your Name:"; my $name =; chomp $name; print "Welcome $name at rookienerd.\n";