in reply to Three argument version of open '>-' (updated)

> Perl::Critic complains about it and wants us to replace it with a three argument variant. But, what's the 3-arg variant of >-?

From a pragmatic point of view, I'd say:

Adjust the Perl::Critic rule!

I mean it's an interesting question, but probably it's not possible to duplicate all these exact implementation details.

This particular 2 args syntax OTOH is documented and legit.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

update

and by all communist gods, why would you like to have a duplicate of STDOUT which fails globally without warning?

Probably this feature is simply broken.

  • Comment on Re: Three argument version of open '>-' (de-critic)

Replies are listed 'Best First'.
Re^2: Three argument version of open '>-' (updated)
by jcb (Parson) on Mar 02, 2021 at 02:41 UTC

    Seconding this: Perl::Critic is simply wrong here. The primary risk of two-argument open is the possibility of a "strange" filename improperly triggering the magic (How about a "file" named 'rm -rf / |'?), but in this case the filename is a literal constant and that is not possible.

    This is a bug in Perl::Critic — your particular use of the two-argument syntax is fine.