Global symbol "$files" requires explicit package name at 1.pl line 19. Execution of 1.pl aborted due to compilation errors (#1) (F) You've said "use strict" or "use strict vars", which indicates + that all variables must either be lexically scoped (using "my" or +"state"), declared beforehand using "our", or explicitly qualified to say which package the global variable is in (using "::").
The variable $files isn't lexical. foreach (and for) uses $_ by default, but if you specify a variable name before the list, it's roughly equivalent to
foreach (@files) { $files = $_; #etc...
So to be properly strict, you need to use my. Here are some examples of odd places where you would have to use my:
for my $i ( 0 .. 10 ) { print "$i\n" } open my $fh, '<', "/etc/passwd"; while (my $line = <>) { next if /^\s*#/ }
In reply to Re: Global symbol .... requires explicit package name at
by bv
in thread Global symbol .... requires explicit package name at
by ZETZ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |