perl-5.38.0
unlink LIST
unlink

Deletes a list of files. On success, it returns the number of files it successfully deleted. On failure, it returns false and sets $! (errno):

LIST に含まれるファイルを削除します。 成功時は削除に成功したファイルの数を返します。 失敗時は偽を返して $! (error) をセットします:

    my $unlinked = unlink 'a', 'b', 'c';
    unlink @goners;
    unlink glob "*.bak";

On error, unlink will not tell you which files it could not remove. If you want to know which files you could not remove, try them one at a time:

エラーの場合、unlink はどのファイルが削除できなかったかを 知らせません。 どのファイルが削除できなかったかを知りたい場合は、一つずつ削除してください:

     foreach my $file ( @goners ) {
         unlink $file or warn "Could not unlink $file: $!";
     }

Note: unlink will not attempt to delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Finally, using unlink on directories is not supported on many operating systems. Use rmdir instead.

注: スーパーユーザ権限で、Perl に -U を付けて実行した場合でなければ、 unlink はディレクトリを削除しようとすることはありません。 この条件にあう場合にも、ディレクトリの削除は、 ファイルシステムに多大な損害を与える可能性があります。 最後に、unlink をディレクトリに使うのはほとんどの OS では 対応していません。 代わりに rmdir を使ってください。

If LIST is omitted, unlink uses $_.

LIST が省略されると、unlink$_ を 使います。