Help for this page

Select Code to Download


  1. or download this
    perl -wMstrict -e "$::x=0; $x++"                        # not OK
    perl -wMstrict -e "package foo; $foo::x=0; $x++"        # not OK
    
  2. or download this
    perl -wMstrict -e "BEGIN{*::x=\$a} $x++"                # not OK (1)
    perl -wMstrict -e "BEGIN{package foo; *::x=\$a} $x++"   # OK     (2)
    
  3. or download this
    perl -wMstrict -e "{package foo; *::x=\$a} $x++"        # not OK
    
  4. or download this
    C:\>perl -MO=Deparse -wMstrict -e "{package foo; *::x=\$a} $x++"
    Variable "$x" is not imported at -e line 1.
    ...
        *main::x = \$a;
    }
    $main::x++;
    
  5. or download this
    perl -wMstrict -e "BEGIN{package bar; *bar::x=\$a} package bar; $x++" 
    +  # not OK
    perl -wMstrict -e "BEGIN{package foo; *bar::x=\$a} package bar; $x++" 
    +  # OK