in reply to Error binmode() on unopened filehandle

make life easier for yourself use Path::Tiny

use Path::Tiny 'path'; my $data = path("foo.txt")->slurp_raw;