Help for this page

Select Code to Download


  1. or download this
    $counter = 0;
    use vars qw($counter);
    
  2. or download this
    my $counter = 0;
    
  3. or download this
    my $counter = 0; # declare and initialize lexical variable
    use vars qw($counter); # declare global variable living in symbol tabl
    +e
    ...
    $main::counter = 1; # initialize $counter in symbol table
    print "\$main::counter: $main::counter\n"; # prints 1
    print "\$counter: $counter\n"; # prints 0