Skip to content

Say 'syntax error near "$"', not the following statement #22038

@jidanni

Description

@jidanni
$ cat $i.pl
for ( 0 .. $ ) {

    #ho hum
    if ( $_ % $n[0] || $_ % $n[1] ) { next; }
    push @o, $_;
}
$ perl -c i.pl
syntax error at i.pl line 4, near "if"
i.pl had compilation errors.

Better would be

syntax error at i.pl line 1, near "$"

Else the user spends over five minutes trying to debug

    if ( $_ % $n[0] || $_ % $n[1] ) { next; }

(True story. In fact the earlier message was
syntax error ... near "next if", causing me to
see if changing next if ... to if () {next}
would help.

What I am trying to say is this time the wild
goose chase was so long that I should have
brought sandwiches.) perl/5.38.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closable?We might be able to close this ticket, but we need to check with the reporter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions