Re: unlink question
[email protected] (Tom Browder) Thu, 9 Oct 2025 09:44:20 -0500
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <CAFMGiz_zHCH=Zx3gDnvWFBB8jf1o71PF5LdZGy1JiCTcYEHeOA@mail.gmail.com> |
On Thu, Oct 9, 2025 at 02:35 ToddAndMargo via perl6-users < [email protected]> wrote: ... I had a problem where this would randomly not > delete the file and not give me the error print > when delete failed: > > if not unlink $OldFileName { > PrintRedErr( "Unable to Delete OldFileName <$OldFileName>\n" ); > } > Todd, what is your intent? Do want to delete an existing? Or not? My choice in general is first determine if it exists. Something like this: if $file.IO.e { # do something with it... } else { # it doesn't exist, so what do i want to do instead? } Of course $file could be a directory! Whenever I want to deal with a collection of files and directories I use the Raku module "File::Find" which helps make such things much easier. Happy Rakuing! -Tom (@tbrowder)