$ perl -c crates
syntax error at crates line 7, near "foreach @line "
crates had compilation errors.
$ perl -Mdiagnostics -c crates
syntax error at crates line 7, near "foreach @line "
crates had compilation errors (#1)
(F) Probably means you had a syntax error. Common reasons include:
A keyword is misspelled.
A semicolon is missing.
A comma is missing.
An opening or closing parenthesis is missing.
An opening or closing brace is missing.
A closing quote is missing.
Often there will be another error message associated with the syntax
error giving more information. (Sometimes it helps to turn on -w.)
The error message itself often tells you where it was in the line when
it decided to give up. Sometimes the actual error is several tokens
before this, because Perl is good at understanding random input.
Occasionally the line number may be misleading, and once in a blue moon
the only way to figure out what's triggering the error is to call
perl -c repeatedly, chopping away half the program each time to see
if the error went away. Sort of the cybernetic version of S<20
questions>.
Uncaught exception from user code:
syntax error at crates line 7, near "foreach @line "
crates had compilation errors.
at crates line 10.
####
$ perldoc perlintro | grep foreach
the more friendly list scanning "foreach" loop.
foreach
foreach (@array) {
print $list[$_] foreach 0 .. $max;
foreach my $key (keys %hash) {
$ perldoc perlsyn | grep foreach
foreach LIST
The "foreach" modifier is an iterator: it executes the statement once
print "Hello $_!\n" foreach qw(world Dolly nurse);
LABEL foreach VAR (LIST) BLOCK
LABEL foreach VAR (LIST) BLOCK continue BLOCK
The "foreach" loop iterates over a normal list value and sets the
loop. This implicit localization occurs *only* in a "foreach" loop.
The "foreach" keyword is actually a synonym for the "for" keyword, so
you can use "foreach" for readability or "for" for brevity. (Or because
"foreach" loop index variable is an implicit alias for each item in the
If any part of LIST is an array, "foreach" will get very confused if you
"foreach" probably won't do what you expect if VAR is a tied or other
foreach $item (split(/:[\\\n:]*/, $ENV{TERMCAP})) {
Perl executes a "foreach" statement more rapidly than it would the
Instead of using "given()", you can use a "foreach()" loop. For example,
requires initialization, such as a subroutine or a "foreach" loop. It
####
$ perl -c crates
Global symbol "$line" requires explicit package name at crates line 7.
crates had compilation errors.
####
$ perl -c crates
crates syntax OK