How to prompt a user for input in Perl

Home > Search > How-to

The following markup can be used to produce a prompt for user input in Perl.


print "Enter your name: ";
my $name = <STDIN>;
chomp $name;

print "Your name is $name";


Here is an example of running this script.

~]# ./
Enter your name: Jeremy
Your name is Jeremy


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.