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. 

#!/usr/bin/perl
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



Comments


Add a Comment


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