Perl
  Home arrow Perl arrow Page 10 - Understanding Perl's Special Variables
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PERL

Understanding Perl's Special Variables
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 30
    2003-07-10

    Table of Contents:
  • Understanding Perl's Special Variables
  • In Default
  • Input...
  • ...And Output
  • Getting Into An Argument
  • The Right Path
  • To Err Is Human
  • A Question Of Ownership
  • Rank And File
  • Calling For A Translator
  • End Zone

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Understanding Perl's Special Variables - Calling For A Translator
    (Page 10 of 11 )

    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

    $/ = $INPUT_RECORD_SEPARATOR

    $\ = $OUTPUT_RECORD_SEPARATOR

    $, = $OUTPUT_FIELD_SEPARATOR

    $? = $CHILD_ERROR

    $@ = $EVAL_ERROR

    $! = $OS_ERROR

    $< = $REAL_USER_ID

    $> = $EFFECTIVE_USER_ID

    $( = $REAL_GROUP_ID

    $) = $EFFECTIVE_GROUP_ID

    $. = $INPUT_LINE_NUMBER

    $0 = $PROGRAM_NAME

    $$ = $PROCESS_ID

    $] = $PERL_VERSION

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


    #!/usr/bin/perl

    use English;

    # set record separator
    $OUTPUT_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 Articles
    More By icarus, (c) Melonfire


     

       

    PERL ARTICLES

    - Perl: A Continuing Look at Hashes and Multid...
    - Perl: Another Round with Hashes
    - Perl Hashes
    - Perl Lists: A Final Look at List::Util
    - Perl Lists: Utilizing List::Util
    - Perl Lists: The Split() Function
    - SQL and CGI with Perl and DBI
    - Perl Lists: More Functions and Operators
    - SELECT Queries and Perl
    - Perl Lists: More on Manipulation
    - Creating a Database with Perl and DBI
    - Perl: Sailing the List(less) Seas
    - Perl and DBI
    - Perl: Concatenating Text and More
    - Perl Text: Quoting Without Quote Marks

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway