Bootstrap FreeKB - Perl (Scripting) - Prompt a user for input (stdin)
Perl (Scripting) - Prompt a user for input (stdin)

Updated:   |  Perl (Scripting) articles

Let's say you want to prompt a user for input, like this.

What is your name?


The following markup can be used to produce the prompt. 

use strict;
use warnings;

print "What is your name? \n";
my $name = <STDIN>;
chomp $name;


In this example, whatever the user types at the prompt will be stored in a variable named $name. The $name variable can be printed to display the users name.

print "Your name is $name \n";


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

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