http://www.perlmonks.org?node_id=892584


in reply to chmod in perl

Have you checked the return status of the chmod command? For instance,

my $filename = q{deletefiles.txt}; chmod 0777, $filename or die $!; open my $OUTPUT, q{+>}, $filename or die $!;

Hope that helps.

Update: 2011-03-11

Fixed missing semicolon on line 2 of code example causing error referred to in Re^2: chmod in perl.

Replies are listed 'Best First'.
Re^2: chmod in perl
by Anonymous Monk on Mar 11, 2011 at 06:18 UTC

    I am getting the following error with the above code

    my $filename = q{deletefiles.txt}; chmod 0777, $filename or die $! open my $OUTPUT, q{+>}, $filename or die $!; Missing comma after first argument to die function at perl.pl line 135 +, near "$filename or" Execution of qdepot_upload.pl aborted due to compilation errors.
      You miscopied the code.

        Actually, I did. I fixed it, and put a note at the bottom to indicate it had been updated, but have no idea if the OP has seen it or tried with the missing semicolon in place.

      Try and put the semicolon after first die statement. Because of that its throwing that error because it's gonna continue till the end of file if you dont specify where to exactly end.