in reply to How to use chmod u +x in perl

Because TMTOWTDI. May I suggest you can also

qx(chmod 0705 '$filename');
or
qx(chmod 0755 '$filename');
These would circumvent any possibility of Perl's misunderstanding the "u+x". If that actually applies.

--Chris

#!/usr/bin/perl -Tw
use Perl::Always or die;
my $perl_version = (5.12.5);
print $perl_version;

Replies are listed 'Best First'.
Re^2: How to use chmod u +x in perl
by Tux (Canon) on Nov 25, 2013 at 16:47 UTC

    Just as what GrandFather was suggesting, this fails badly if $filename has a ' in the name. IF you'd choose a system call instead of the builtin chmod, then at least do it the safe way:

    system "chmod", "u+x", $filename;

    If someone cares to set the x bit on a PDF document, it is likely that the document name is littered with unexpected characters.

    In the end I'd advice NOT to use system or qx{} to do a simple chmod. Not even to give a fast and simple workaround. I think it is bad advice.


    Enjoy, Have FUN! H.Merijn