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


Graphics & Media Lab. >> Библиотека | Курсы | Графикон

Hosted by Graphics & Media Lab
http://graphics.cs.msu.su
lab_logo
mailto: Laboratory