Increment/decrement automatically
  1. Create a new script with this code:

    #!/usr/bin/perl
    print "Content-Type: text/html \n\n";

    $cars_on_lot = 10;

    print "We have $cars_on_lot cars.\n
    ";

    print "We got another new car.\n
    ";

    $cars_on_lot++;

    print "Now we have $cars_on_lot cars!\n<p>";

    print '<b>$cars_on_lot++</b> is the same to PERL as <b>$cars_on_lot + 1.</b>';
  2. Save the script as autoplus.pl in the PERLSCRIPTS folder.

    Here's what the relevant lines in this script do:
  • $cars_on_lot++;

    The auto incrementer (++) adds 1 to the $cars_on lot variable.

  • print '<b>$cars_on_lot++</b> is the same to PERL as <b>$cars_on_lot = $cars_on_lot + 1</b>';

    Prints the literal text: $cars_on_lot++ is the same to Perl as $cars_on_lot + 1.