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

End Zone - 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



And that's about it for this tutorial. Over the preceding few pages, I
introduced you to the following special variables in Perl:

$_ (the default variable)

$/ (the input record separator)

$\ (the output record separator)

$, (the output field separator)

@ARGV (the command-line argument array)

@_ (the subroutine argument array)

@INC (the include path array)

%ENV (the environment variable array)

$? and $! (the last error code)

$@ (the last error in an eval() block)

$<, $>, $) and $( (the real and effective UID/GIDs)

$. (the line number of an input file)

$ARGV (the name of an input file)

$0 (the name of the current script)

$$ (the process ID of the current script)

$[ (the Perl version number)

Of course, these are just some of the more commonly-used creatures you'll
encounter in your travels through the Perl universe. Perl has a whole bunch
more of these special variables which have not been discussed here - you
can find them all in the "perlvar" manual page. Take a look for yourself,
and until we meet again...stay healthy!

Note: Examples are illustrative only, and are not meant for a production
environment. Melonfire provides no warranties or support for the source
code described in this article. YMMV!

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