$file.IO.slurp and slurp($file) are basically the same. $handle.slurp-rest does *not* close the handle, as another process might still be writing to it, so you could do another .slurp-rest.
To get back to your original code: get '/atom' => sub { my $path = $.meta ~ request.path; return open($path).slurp-rest; } I would write that as: get '/atom' => sub { slurp $.meta ~ request.path } Should you wind up with an opened handle, could could use a LEAVE phaser to make sure the handle gets closed: get '/atom' => sub { LEAVE $.meta.handle.close; return $.meta.handle.slurp-rest; } HTH, Liz ===================== > On 25 Mar 2017, at 17:12, Gabor Szabo <szab...@gmail.com> wrote: > > Oh so you say that's indeed a bug in my code. That's a relief. Thanks! > > > As I can see I had some $file.IO.slurp and some of the slurp-rest ones. > > What is the difference between $file.IO.slurp and slurp($file) ? > Is the latter just an alias for the former? > > Gabor > > > On Sat, Mar 25, 2017 at 4:54 PM, Timo Paulssen <t...@wakelift.de> wrote: >> i highly suggest you slurp instead of open + slurp-rest, because that >> will automatically close the file for you, too. >> >> other than that, you can pass :close to the slurp-rest method and it'll >> also close the file. >> >> if you're not closing the files you're opening, you'll be relying on the >> garbage collector to do file handle closing for you, which is >> nondeterministic and a bad idea in general. >> >> HTH >> - Timo