Also, strict won't complain if you fully qualify the package variables. For example:
strict nixed the first one-liner, but the second one worked fine.% perl -le 'use strict; $x = 1; print $x' Global symbol "$x" requires explicit package name at -e line 1. Global symbol "$x" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors. % perl -le 'use strict; $main::x = 1; print $::x' 1
In your case you can use $main::INPUT, or, taking advantage of the special treatment given to the main package, you can also use $::INPUT (I used both forms of qualification in the second one-liner, for the sake of illustration).
But I concur with nobull that you should read perlmod so that you better understand Perl5's module scheme. (Good follow-up reading after perlmod are perltoot and perlobj.)
Update: One more thing about strict: if you want to bypass it, instead of postponing the use strict line until after the last place in the code that make it complain (as you did in auth.pl), the thing to do is to turn strict off in a block set up for the purpose, like this:
You will often see this sort of thing, especially the more limited version of it, such as:use strict; # ... code under strict { # strict-free block no strict; $nya_nya = 1; } # ... code under strict
This example is certainly contrived, but it is common to run into real cases in which you have the name of a sub or a method in a string, and you want to be able to execute it; one way to do it is to switch off strict 'refs' in a narrow scope. As you can see, in the absence of strict's surveillance, perl will interpret the string 'foobar' as if it were a reference to the subroutine foobar. (Without the no strict 'refs' line you'd get a compile time error: Can't use string ("foobar") as a subroutine ref while "strict refs" in use....)use strict; sub foobar { print "hello from foobar\n" } my $sub_name = 'foobar'; { no strict 'refs'; $sub_name->(); } __END__ hello from foobar
the lowliest monk
In reply to Re: using strict setup
by tlm
in thread using strict setup
by tanger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |