develooper Front page | perl.perl5.porters | Postings from March 2011

Re: [perl #86794] Problem with Fcntl inlining subroutines (e.g.S_ISDIR S_IXUSR)

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
March 23, 2011 06:47
Subject:
Re: [perl #86794] Problem with Fcntl inlining subroutines (e.g.S_ISDIR S_IXUSR)
Message ID:
20110323134750.GM2900@iabyn.com
On Tue, Mar 22, 2011 at 03:45:01PM -0700, rebx wrote:
> I'm having some problems migrating a running code from v5.8.8 to 5.10.1

This is because your code that "worked" under 5.8.8 was silently
misbehaving; 5.10.0 just points out that your code is incorrect.

> Here's the error I'm getting from my test
> 
> # perl fcntltest.t 
> Too many arguments for main::S_IXUSR at fcntltest.t line 19, near "])"
> Execution of fcntltest.t aborted due to compilation errors.
> # Looks like your test exited with 255 before it could output anything.

That's because S_IXUSR etc are documented to be *constants*, not functions.

> ok (S_IXUSR($stat[2]), "test $file is executable by the user");
> ok (S_ISREG($stat[2]), "test $file is a file");

If you look carefully, you'll see that under 5.8.8, that first line always
succeeds, even if the file isn't executable. In fact, under 5.8.8, even
the following returns true:

    S_IXUSR(0,0,0,0)

You need to change your code to

($stat[2] & S_IXUSR)

HTH.

-- 
Standards (n). Battle insignia or tribal totems.

Thread Previous | 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