Home arrow Perl Programming arrow Page 2 - Beginning Programming Perl(s)

Storing Data in A Variable - Perl

In the last article, you learned how to install Perl. It wouldn't make a lot of sense to install it on your computer if you never did anything with it, now would it? In this article, you'll take your first steps to becoming part of a wild and crazy breed -- a Perl programmer.

TABLE OF CONTENTS:
  1. Beginning Programming Perl(s)
  2. Storing Data in A Variable
  3. Quoth the Raven
  4. List Data Types
By: James Payne
Rating: starstarstarstarstar / 9
October 10, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

There are many ways to store data in a variable. For now we will focus on the below example:


$my_name = 'Hamburglar; ' # places the name Hamburglar in the variable

$my_iq = 1000; # places the value 1,000 in the variable

You'll note the # symbol followed by text above. This is known as a comment. Comments are lines of text that the computer cannot see. They are used to let other programmers (and even yourself) know what you intended a line of code to do. When the computer sees the # symbol, it skips the remainder of that line and moves on to the next.

Try the following code:


#!/usr/local/bin/perl

$my_name = 'James';

print "My name is below:n";

print "$my_namen";

The above code will print out the following to your screen:

  My name is below:

  James

You will notice a few new additions to our code. The first is the line:


#!/usr/local/bin/perl

This must appear on the first line of every program you create. It tells the computer which directory to look in.

In addition, we added the print command, which tells the program to print something to the screen. And lastly, we added the n or new line code. This simply informs the program to go to the next line and not print the next line of text on the same line.



 
 
>>> More Perl Programming Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PERL PROGRAMMING ARTICLES

- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: