in reply to requires explicit package name
The error is from use strict - which is good. Also check you have use warnings.
This type of problem is (almost) always due to bad code which isn't a syntax error. For instance, a stray double-quote on a line above could be wrapping my $num in a string. Mismatched parentheses, brackets or braces around this code are likely candidates. A missing semicolon to terminate a statement is another possibility. There could be other reasons.
The line where the error is reported is important - you haven't shown that here.
If you can't find the problem through simple visual inspection, try commenting out a line near the error and see if you get different (more useful) messages.
I also find it good practice to keep a mental catalogue of silly mistakes I make often and check for those first. For example, I often don't release the Shift key quickly enough, resulting in a colon, rather than a semicolon, at the end of the line, e.g.
$var1 = $hash{$key}: $var2 = some_sub(@args):
Use of an editor with syntax highlighting can also sometimes help in this situation. I understand that is a personal choice and some people prefer not to use syntax highlighting.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: requires explicit package name
by toniax (Scribe) on Nov 12, 2010 at 19:50 UTC |