How Do You Do File Locking in Raku?
I've come across these Raku-idiomatic phrases and use them a lot, with 'given' topicalizing for brevity/clarity:
Read:
given $path.IO.open {
.lock: :shared;
%data = from-json(.slurp);
.close;
}
Write:
given $path.IO.open(:w) {
.lock;
.spurt: to-json(%data);
.close;
}
IO::Handle has a lock and an unlock method to lock/unlock files. Locks can be exclusive or shared.