Home arrow Perl Programming arrow Page 10 - Understanding Perl's Special Variables

Calling For A Translator - Perl

Perl comes with a whole bunch of cryptically-named built-invariables, which clever Perl programmers exploit to reduce the number oflines of code in their scripts. This article examines some of the morecommonly-used special variable in Perl, with examples and illustrations ofhow they may be used.

  1. Understanding Perl's Special Variables
  2. In Default
  3. Input...
  4. ...And Output
  5. Getting Into An Argument
  6. The Right Path
  7. To Err Is Human
  8. A Question Of Ownership
  9. Rank And File
  10. Calling For A Translator
  11. End Zone
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 38
July 10, 2003

print this article



Now, while the cryptic variable names discussed over the preceding pages
are frequently-used by experienced Perl developers. novice users might find
them a little disconcerting (at least in the beginning). That's why Perl
also provides for alternative syntax, in the form of longer, more-readable
English-language equivalents for the variables discussed previously.

In order to use the more-readable human-language names, simply add the line

use English;

to the top of your Perl script.

You should now be able to use Perl's longer names for the special variables
discussed in this tutorial, thereby adding greater readability to your
script. Here's a list mapping the special variables discussed above to
their longer names:

$_ = $ARG






$! = $OS_ERROR









Consider the following variant of a previous example, which demonstrates
how they may be used:


use English;

# set record separator

# print user and group
print "This script is running as " . getpwuid($EUID) . " who belongs to the
following groups:";

foreach (split(" ", $))) { print scalar(getgrgid($ARG)); };

>>> More Perl Programming Articles          >>> More By icarus, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: