What's the best way to open and read a file in Perl?

前端 未结 12 1939
醉话见心
醉话见心 2020-11-27 13:11

Please note - I am not looking for the \"right\" way to open/read a file, or the way I should open/read a file every single time. I am just interested to find out what way m

12条回答
  •  有刺的猬
    2020-11-27 13:37

    If your files are small enough that reading the whole thing into memory is feasible, use File::Slurp. It reads and writes full files with a very simple API, plus it does all the error checking so you don't have to.

提交回复
热议问题