in reply to Strict Variables without "my"

You can also declare your variables with "our". That way they aren't restricted to the subroutine or block.

Replies are listed 'Best First'.
Re: Variables
by Abigail-II (Bishop) on Aug 07, 2002 at 14:15 UTC
    Well, they are. Sort of. our creates an alias to a package variable. That is, our $foo is an alias to $PACKAGE::foo, where PACKAGE is your current package. The package variable will always exist, but the alias is lexically scoped.
    use strict; $main::foo = 1; { our $foo; print $foo, "\n"; } # print $foo, "\n"; print $main::foo, "\n";
    This prints 1\n1\n. But if you remove the #, the code doesn't compile.

    Abigail