# PERL - <STDIN>

<STDIN> stands for standard input. It can be abbreviated by using simple <>. By declaring a scalar variable and setting it equal to <STDIN> we set the variable equal to whatever will be typed by our user at the command prompt. Observe:

## whatismyage.pl:

```#! usr/bin/perl
print "How old are you?";
\$age = <>;
print "WOW! You are \$age years old!";
```

## How old are you?:

Don't worry about the display being a little off the mark, we will cover the formatting in the next lesson. For now let's practice retrieving some user input using PERL.

Let's take this example one step further and also request the favorite color of our user.

## agencolor.pl:

```#! usr/bin/perl
print "How old are you?";
\$age = <>;
print "What is your favorite color?";
\$color = <>;
print "You are \$age, and your favorite color is \$color.";
```

## Age 'N' Color:

Once again, our formatting leave a little to be desired, but the variables are working as they should, and for now this is all we need to know.

# PERL - Beginning Scripting

You now have the knowledge required to code some mathematical scripts like the following.

## circle.pl:

```#! usr/bin/perl
print "What is the radius of the circle?";
chomp (\$r = <>);
\$diameter = (2 * \$r);
\$area = (3.14 * (\$r ** 2));
\$cir = (\$diameter * 3.14);
print "Radius: \$r\n Diameter: \$diameter\n Circumference: \$cir\n Area: \$area";
```

# Found Something Wrong in this Lesson?

Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!

 Web Reference HTML Reference CSS Reference CSS Examples PHP Examples Help Tizag Grow Link to Tizag Tizag.com Store
 Advertise Here More Tutorials! Microsoft Office Tutorials Artist Tutorials