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
Dave Mitchell
March 23, 2011 06:47
Re: [perl #86794] Problem with Fcntl inlining subroutines (e.g.S_ISDIR S_IXUSR)
Message ID:
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:


You need to change your code to

($stat[2] & S_IXUSR)


Standards (n). Battle insignia or tribal totems.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About