develooper Front page | perl.perl5.porters | Postings from January 2004

open/or inconsistency

Thread Next
From:
H.Merijn Brand
Date:
January 16, 2004 05:16
Subject:
open/or inconsistency
Message ID:
20040116140945.D1D9.H.M.BRAND@hccnet.nl
why are

open my $fs, $path or die "reason";
open my $fs, $path ore return ();

allowed, and is

open my $fs, $path or return;

not? Note the missing parens, which I realy don't want here
IMHO a bug

# perl5.6.1 xx
Parentheses missing around "my" list at xx line 11.
# perl5.8.0 xx
Parentheses missing around "my" list at xx line 11.
# perl5.8.3 xx
Parentheses missing around "my" list at xx line 11.
# perl5.9.0 xx
Parentheses missing around "my" list at xx line 11.

--8<--- xx
#!/pro/bin/perl

use strict;
use warnings;

my $path = "/dev/null";
open my $fs, $path or die "$path: $!";

sub func ()
{
    open my $fs, $path or return;
    } # func
func;

sub funk ()
{
    open my $fs, $path or return ();
    } # funk
funk;
-->8---

# perl -MO=Deparse xx
Parentheses missing around "my" list at xx line 11.
use warnings;
use strict 'refs';
my $path = '/dev/null';
die "${path}: $!" unless open my $fs, $path;
sub func () {
    return unless open my $fs, $path;
}
func;
sub funk () {
    return +() unless open my $fs, $path;
}
funk;
xx syntax OK



-- 
H.Merijn Brand        Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0, & 5.9.x, and 806 on  HP-UX 10.20 & 11.00, 11i,
   AIX 4.3, SuSE 8.2, and Win2k.           http://www.cmve.net/~merijn/
http://archives.develooper.com/daily-build@perl.org/   perl-qa@perl.org
send smoke reports to: smokers-reports@perl.org, QA: http://qa.perl.org


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About