Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 42384
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: KYLE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: ProhibitTwoArgOpen should allow '-|' and '|-'
I've sometimes used code like this to spawn a child with a pipe for communication: my $pid = open my $child_fh, '-|'; perlcritic complains about this as a two-arg-open, but there's nothing wrong with it.
I've fixed this in a branch, rt42384.
The attached patch against the branch updates the associated documentation and tests for re-opening STDIN & STDOUT.
Index: distributions/Perl-Critic/t/InputOutput/ProhibitTwoArgOpen.run =================================================================== --- distributions/Perl-Critic/t/InputOutput/ProhibitTwoArgOpen.run (revision 2970) +++ distributions/Perl-Critic/t/InputOutput/ProhibitTwoArgOpen.run (working copy) @@ -46,7 +46,16 @@ $foo{open}; # not a function call -# There is no three-arg equivalent for these +#----------------------------------------------------------------------------- + +## name no three-arg equivalent passes +## failures 0 +## cut + +open( STDOUT, '>&STDOUT' ); +open( STDIN, '>&STDIN' ); +open( STDERR, '>&STDERR' ); + open( \*STDOUT, '>&STDERR' ); open( *STDOUT, '>&STDERR' ); open( STDOUT, '>&STDERR' ); Index: distributions/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm =================================================================== --- distributions/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm (revision 2970) +++ distributions/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/ProhibitTwoArgOpen.pm (working copy) @@ -69,6 +69,8 @@ =pod +=for stopwords perlipc + =head1 NAME Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen - Write C<< open $fh, q{<}, $filename; >> instead of C<< open $fh, "<$filename"; >>. @@ -111,9 +113,9 @@ =head1 NOTES -The only time you should use the two-argument form is when you re-open -STDIN, STDOUT, or STDERR. But for now, this Policy doesn't provide -that loophole. +There are two cases in which you are forced to use the two-argument form of +open. When re-opening STDIN, STDOUT, or STDERR, and when doing a safe pipe +open, as described in L<perlipc|perlipc>. =head1 SEE ALSO
On Fri Jan 16 13:07:40 2009, LJOHNSON wrote: Show quoted text
> The attached patch against the branch updates the associated > documentation and tests for re-opening STDIN & STDOUT.
Thank you! I've applied this to my branch.
Subject: Re: [rt.cpan.org #42384] ProhibitTwoArgOpen should allow '-|' and '|-'
Date: Sat, 17 Jan 2009 14:26:00 -0600
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Kyle Hasselbacher via RT wrote: Show quoted text
> I've fixed this in a branch, rt42384.
Merged to trunk.
This has been fixed and released as Perl-Critic-1.095_001 to a CPAN near you. Thanks for reporting this bug. -Jeff