Help for this page

Select Code to Download


  1. or download this
    {
       my $var;
    }
    # $var no longer exists.
    
  2. or download this
    package main;
    
    ...
    
    print("$main::var\n");  # Prints 5.
    #print("$var\n");       # Error!
    
  3. or download this
    $main::var = 1;
    
    ...
    } # Restores saved value of $main::var.
    
    print("$main::var\n");  # Prints 1.
    
  4. or download this
    package main;
    
    ...
    } # Restores saved value of $main::var.
    
    print("$var\n");      # Prints 1.
    
  5. or download this
    sub recursive {
       our $state;
    ...
    
       ...
    }
    
  6. or download this
    my $var = 1;
    our $alias;
    *alias = \$var;
    $alias = 2;
    print("$var\n");   # 2