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

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

Replies are listed 'Best First'.
Void context
by rir (Vicar) on Mar 08, 2003 at 18:29 UTC
    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.

        Great. Thanks.

        Guess I'm going have to make an effort to catch up on the parts of Perl I "know". And guts was getting so tempting.

        rir -- only about seven years behind the times