in reply to Re^4: chmod in perl
in thread chmod in perl

The problem with the below code is if the file doesnot exist,you will get an error "No such file or directory at perl.pl line 135

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

Replies are listed 'Best First'.
Re^6: chmod in perl
by ikegami (Patriarch) on Mar 11, 2011 at 18:37 UTC

    Either ignore that error,

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

    Or change the permissions after creating the file.