PP.
PP.

Reputation: 10865

Disable Perl warnings for missing qw outer parentheses

Since upgrading Debian recently I've had Perl whining about not having extra parentheses around the qw operator.

As a Systems Administrator this is unacceptable. It is breaking mod_perl applications left, right, and centre.

How can I run Perl with this warning disabled? Is there a flag I can run with the Perl interpreter? Note that editing source is not an option.

Upvotes: 2

Views: 4311

Answers (2)

Dave Cross
Dave Cross

Reputation: 69314

This changed in Perl 5.14 - see perldelta.

Use of qw(...) as parentheses

Historically the parser fooled itself into thinking that qw(...) literals were always enclosed in parentheses, and as a result you could sometimes omit parentheses around them:

for $x qw(a b c) { ... }

The parser no longer lies to itself in this way. Wrap the list literal in parentheses like this:

for $x (qw(a b c)) { ... }

This is being deprecated because the parentheses in for $i (1,2,3) { ... } are not part of expression syntax. They are part of the statement syntax, with the for statement wanting literal parentheses. The synthetic parentheses that a qw expression acquired were only intended to be treated as part of expression syntax.

Looks like you can turn the warnings off with no warnings 'qw' but you'd be far better off fixing the code.

Upvotes: 8

Michael Hampton
Michael Hampton

Reputation: 10000

As a system administrator I find bad code unacceptable.

The best answer, of course, is to fix the offending perl scripts.

If your business won't let you fix the offending perl scripts, then don't upgrade Debian.

You have risks either way.

Upvotes: 5

Related Questions