in reply to Why doesn't chmod work on this lexical filehandle?

1) your system must support fchmod for it to work. 2) you should be using globs or glob references. 3) I don't think it works with closed file handles. 4) Did you check the return value of chmod, and $! if it's false?

Replies are listed 'Best First'.
Re^2: Why doesn't chmod work on this lexical filehandle?
by williff (Initiate) on Feb 14, 2011 at 21:56 UTC

    Thanks for great suggestions. Moved close after chmod but it did not help.

    Working on Linux box, uname -a says: Linux ... 2.6.9-89.0.16.ELxenU #1 SMP Tue Oct 27 04:12:25 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

    chmod returns 0 and $! returns "No such file or directory" even after moving close after chmod.

    will investigate globs, glob refs. I think those are used in main, but a scalar ref was used with this sub.

      Then it sounds like $OUT is being interpreted as a string and that that string is being interpreted as a file name: If chmod had thought that you had passed a file handle to it on a system where Perl doesn't think fchmod() is supported, then it would have died rather than returning 0. If you passed a file handle to chmod() on a system with fchmod, "No such file or directory" could not have been the failure reason.

      - tye        

        Yes! This is the problem. Our default perl at /usr/local/bin/perl is a symlink to 5.8. When i pointed to the latest version installed, which was 5.10.1, then the code works great. Thank you. And thanks to all Perl Monks sharing their wisdom and debug tips.