Catalyst’s path_to method returns a Path::Class object. Path::Class has three methods for opening files: open, openw, and openr. The first, open, can be called with the equivalent arguments for reading and writing: r|w.

path_to has a limitation though. It’s specific to your application directory. It won’t let you get the path for anything outside. You can see however that it is an easy, portable way to get files and their handles within Cat so why not use it for other things too.

First, a file to use

cat ./etc/file_system/README

This is a file for your MyApp::Model::File to find.

You can see we’ve picked a nice safe spot for our file based model: etc/file_system. This isn’t necessary, it’s just a way to do it to know you’re not going to accidentally serve files that will cause security problems.