in reply to Re: Operator precedence (void context)
in thread Operator precedence (or, I'm an idiot)

With the routine the $var may vary.

Even with:

sub rout { &blah; 1; }
there may be side effects.

Replies are listed 'Best First'.
Re^3: Operator precedence (void context)
by tye (Sage) on Mar 07, 2003 at 22:32 UTC

    Of course there may be side effects. That is why you don't have to use -w. But there is no good reason to use grep and/or map solely for their side effects and there are good reasons to not do so. The warning would be:

    Use of map/grep in void context, use foreach instead
    If you have some perverse reason for doing such, then just turn off that warning. For people wanting help in catching simple errors, the warning will be useful.

                    - tye
      As to how Perl can be improved. I agree with tye, map and grep should generate a warning in void context. I'd leave out the foreach recommendation except under diagnostics.

      In the same vein, Perl should have a wantvoid or wantbool operator so that the general case can be handled.