Re: Raku IO IceDrive bug

[email protected] (Ralph Mellor)
Newsgroups perl.perl6.users
Message-ID <CAPLR5Sdq+1k8C8kbBRRA-=1y-JzG3n0w8=tX1KH7u1tbYqr-kQ@mail.gmail.com>
> if not FileExists( $WanIpFileName )  {
>     $WanIpFileName.IO.open(:w);
>     spurt "$WanIpFileName", "New File Opened";
> }

Afaik, depending on how you choose to look at things,
there's a doc error (doc for `spurt` doesn't mention that
it opens the file it's spurting to), and/or behavior due to
your Windows file system / account settings that leads
to the issue you see, and/or a bug in your code.

Let me explain. Here's what the code does:

1. Opens the file with `$WanIpFileName.IO.open(:w);`
if it doesn't already exist.

2. Opens the file with `spurt` and writes to it.

And that causes the behavior you see.

Presumably, on your system/setup, doing those two things
fails because the second open fails due to the first one.

So it succeeds the second time around because the file
already exists (though blank) and the `spurt` goes ahead.

I'd argue that the bug is ultimately in your code, perhaps
due to you not realizing that `spurt` opens the file it spurts
to, because the doc doesn't say so.

Whichever way one looks at it, there's no bug in Raku(do).

--
love, raiph
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.