Variables
Variables
To do anything useful, you need to be able to store values
in temporary locations and perform manipulations on them.
We all know these as "variables." Perl actually
has several kinds of variables, known more generically as
"data structures." We'll use word "variable"
to talk about a specific instance of a data structure (or "data type").
Some data types you may be familiar with:
- C:
int, float, char, struct
- C++: class
- Fortran: integer, real, character
All of the above are "strongly typed," which means you must explicitly
declare variables before you use them. Languages such as lisp or smalltalk
do not work this way - data types are determined dynamically, and if
a variable holds a number, the programmer is responsible for making sure
that the program doesn't try to pull substrings out of it.
All languages have internal representations
for the different data types, they just vary in how much the programmer
assists in making sure the variable is in the right form.
Perl falls in the middle. Which data type you use explicit in how
you access it, but you don't need to declare it before you use it.
The National Center for Supercomputing Applications
University of Illinois at Urbana-Champaign
johnsonb@ncsa.uiuc.edu
Last modified: June 19, 1997
|
Retrieved by Memoweb from http://www.ncsa.uiuc.edu/General/Training/PerlIntro/variables.html at 08/02/99