# Perl Programming/Scalar variables
## Scalar Variables
### Introduction to Scalar Variables

Now that you understand how to use strings and numbers in Perl, you need to start learning how to use variables. The best way to learn about scalar variables - Perl talk for a single variable, as against a group or list of values - is to look at an example.
Now let's break this program down:
* The first two lines you already know, #!/usr/bin/perl and use warnings;
* The third line is more interesting, it contains a scalar variable. There are a few important things to point out:
** In case you haven't figured this out, the scalar variable in this line is $my_scalar_variable
** Notice the $ before the name my_scalar_variable, in order to define a scalar variable, this sign must appear before the name.
* Now let's look at the last line. This is just the familiar print function being told to print the value of $my_scalar_variable.

### Assigning and Using Scalar Variables

In the course of writing a program, you will most likely use a variable. What is a variable? A variable is something that stores data. A scalar variable holds a single value.

#### Naming Conventions

* All scalar variables names must start with a $ symbol. You can remember this by thinking $scalar.
* Variable names can be comprised of alphanumeric characters and underscores.
* Numeric characters are allowed in names of variables, but not as the first character after the $.

#### Using Scalar Variables
##### Scalar Variables and Strings

You may recall that earlier in the book, I said that whether you use " or ' in strings makes a big difference in the interaction of strings and variables. Well now I am going to explain what I meant.
Now that you know what a variable is, what if you wanted to put a variable in a string? Here's the difference:
* With a double quoted string, this program:
Would return "I saw 4 lions!"
* With a single quoted string, this program:
Would return "I saw $variable lions!"
This effect is because of what I said before, single quoted strings are interpreted literally.

### Comparison Operators

    Main article: Perl Programming/Operators
There are operators that are used for comparing numbers and strings. This can be very useful when you get to more advanced programming. Both numbers and strings have their own set of operators which test for a condition such as equal or not equal and return either true or false.

#### Numeric Comparison Operators

Here is the list of numeric comparison operators:
* == - Equal to
* != - Not equal to
* < - Less than
* > - Greater than
* <= - Less than or equal to
* >= - Greater than or equal to
* <=> - Numeric Comparison

#### String Comparison Operators

Here is the list of string comparison operators:
* eq - Equal to
* ne - Not equal to
* lt - Less than
* gt - Greater than
* le - Less than or equal to
* ge - Greater than or equal to
* cmp - String Comparison

### Exercises

* Try writing a program like the Hello World program except elaborate it by storing "Hello, world!\n" in a variable and then printing the variable.
* Play around with all the things we have learned so far. Try to create a program that has an example of everything we have learned so far.