mpersico has asked for the wisdom of the Perl Monks concerning the following question:

The inverse of File::Slurp - take data and a file and write it all out. I seem to remember it existing at some point in the past, but I cannot for the life of me find it. Any ideas of what I might have been thinking about?
  • Comment on File::Spew - a figment of my imagination?

Replies are listed 'Best First'.
Re: File::Spew - a figment of my imagination?
by Your Mother (Archbishop) on Sep 09, 2015 at 16:31 UTC

    You might be thinking of IO::All, but I second the recommendation for Path::Tiny for file tree work.

Re: File::Spew - a figment of my imagination?
by RichardK (Parson) on Sep 09, 2015 at 16:40 UTC

    File::Slurp has a write_file method, doesn't that do what you want?

      File::Slurp is broken, especially with regard to character encoding and I/O layers. It should be eschewed. File::Slurper is a modern replacement, or use Path::Tiny.

      The way forward always starts with a minimal test.

        OH! Is it still broken 4+ years later?

Re: File::Spew - a figment of my imagination?
by 1nickt (Canon) on Sep 09, 2015 at 16:05 UTC

    No idea what you were thinking about :-)

    But you can use Path::Tiny for slurping and spewing.

    The way forward always starts with a minimal test.
Re: File::Spew - a figment of my imagination?
by mpersico (Monk) on Sep 09, 2015 at 16:40 UTC

    Ugh - Now I remember. I was going to submit a patch to File::Slurp such that:

    *spew = \&write_file

    Never mind...

Re: File::Spew - a figment of my imagination?
by Laurent_R (Canon) on Sep 09, 2015 at 16:11 UTC
    Hum, what is your data looking like? A scalar? An array? Some other data structure? In many cases, you don't need to unroll a loop, and in some cases you can just print the array within quote marks to the file handle.