logo

internet.com
Join the free
WDVL newsletter!

home

Using Scalars

Using scalar variables

  • The benefit of substituting a scalar variable name for a value is that we can then manipulate its value. For example, you can "auto-increment" a scalar variable using the "++" operator:

    $number = 1; 
    print "$number\n"; 
    $number++; 
    print "$number\n"; 
    

  • Perl would send the following to standard output

    1
    2
    

  • You can also perform arithmetic such as:

    $item_subtotal = $item_price * $quantity; 
    $shipping_price = 39.99 * $quantity; 
    $grand_total = $item_subtotal +
    $shipping_price; 
    

  • Scalar variables are the meat and potatoes of CGI. After all, translating between the client and the Web server is essentially the formatting and the reformatting of variables. Be prepared to see them used a lot.

Perl Scalars
Table of Contents
Using the "." Operator

Up to => Home / Authoring / Scripting / Tutorial

Instantly look up a "techie" word using Webopedia!!


internet.com
e-commerce
WebDeveloper Network


Live coverage of Fall Internet World '99!

Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.

www.internet.com