<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    IO::Barf - Barfing content to output file.

SYNOPSIS
     use IO::Barf qw(barf);
     barf($file_or_handler, 'CONTENT');

SUBROUTINES
    "barf($file_or_handler, $content)"
             Barf content to file or handler.

ERRORS
     barf():
             Cannot open file '%s'.
             Cannot close file '%s'.
             Unsupported reference '%s'.

EXAMPLE1
     use strict;
     use warnings;

     use File::Temp;
     use IO::Barf;

     # Content.
     my $content = "foo\nbar\n";

     # Temporary file.
     my $temp_file = File::Temp-&gt;new-&gt;filename;

     # Barf out.
     barf($temp_file, $content);

     # Print tempory file.
     system "cat $temp_file";

     # Unlink temporary file.
     unlink $temp_file;

     # Output:
     # foo
     # bar

EXAMPLE2
     use strict;
     use warnings;

     use IO::Barf;

     # Content.
     my $content = "foo\nbar\n";

     # Barf out.
     barf(\*STDOUT, $content);

     # Output:
     # foo
     # bar

EXAMPLE3
     use strict;
     use warnings;

     use Benchmark qw(cmpthese);
     use IO::All;
     use IO::Any;
     use IO::Barf;
     use File::Slurp qw(write_file);
     use File::Temp;
     use Path::Tiny;

     # Temporary files.
     my $temp1 = File::Temp-&gt;new-&gt;filename;
     my $temp2 = File::Temp-&gt;new-&gt;filename;
     my $temp3 = File::Temp-&gt;new-&gt;filename;
     my $temp4 = File::Temp-&gt;new-&gt;filename;
     my $temp5 = File::Temp-&gt;new-&gt;filename;

     # Some data.
     my $data = 'x' x 1000;

     # Benchmark (10s).
     cmpthese(-10, {
             'File::Slurp' =&gt; sub {
                     write_file($temp3, $data);
                     unlink $temp3;
             },
             'IO::All' =&gt; sub {
                     $data &gt; io($temp4);
                     unlink $temp4;
             },
             'IO::Any' =&gt; sub {
                     IO::Any-&gt;spew($temp2, $data);
                     unlink $temp2;
             },
             'IO::Barf' =&gt; sub {
                     barf($temp1, $data);
                     unlink $temp1;
             },
             'Path::Tiny' =&gt; sub {
                     path($temp5)-&gt;spew($data);
                     unlink $temp5;
             },
     });

     # Output like this:
     #                Rate  Path::Tiny     IO::Any     IO::All File::Slurp    IO::Barf
     # Path::Tiny   3210/s          --        -17%        -51%        -85%        -91%
     # IO::Any      3859/s         20%          --        -41%        -82%        -89%
     # IO::All      6574/s        105%         70%          --        -70%        -81%
     # File::Slurp 21615/s        573%        460%        229%          --        -39%
     # IO::Barf    35321/s       1000%        815%        437%         63%          --

EXAMPLE4
     use strict;
     use warnings;

     use Benchmark qw(cmpthese);
     use File::Temp;

     # Temporary files.
     my $temp1 = File::Temp-&gt;new-&gt;filename;
     my $temp2 = File::Temp-&gt;new-&gt;filename;
     my $temp3 = File::Temp-&gt;new-&gt;filename;
     my $temp4 = File::Temp-&gt;new-&gt;filename;
     my $temp5 = File::Temp-&gt;new-&gt;filename;

     # Some data.
     my $data = 'x' x 1000;

     # Benchmark (10s).
     cmpthese(-10, {
             'File::Slurp' =&gt; sub {
                     require File::Slurp;
                     File::Slurp::write_file($temp3, $data);
                     unlink $temp3;
             },
             'IO::All' =&gt; sub {
                     require IO::All;
                     $data &gt; io($temp4);
                     unlink $temp4;
             },
             'IO::Any' =&gt; sub {
                     require IO::Any;
                     IO::Any-&gt;spew($temp2, $data);
                     unlink $temp2;
             },
             'IO::Barf' =&gt; sub {
                     require IO::Barf;
                     barf($temp1, $data);
                     unlink $temp1;
             },
             'Path::Tiny' =&gt; sub {
                     require Path::Tiny;
                     path($temp5)-&gt;spew($data);
                     unlink $temp5;
             },
     });

     # Output like this:
     # TODO

DEPENDENCIES
    Error::Pure, Exporter, Readonly, Scalar::Util.

SEE ALSO
    IO::Any
        open anything

    File::Slurp
        Simple and Efficient Reading/Writing/Modifying of Complete Files

    Perl6::Slurp
        Implements the Perl 6 'slurp' built-in

REPOSITORY
    &lt;https://github.com/tupinek/IO-Barf&gt;

AUTHOR
    Michal Josef �麖a�嶤k &lt;mailto:skim@cpan.org&gt;

    &lt;http://skim.cz&gt;

LICENSE AND COPYRIGHT
     穢 2009-2020 Michal Josef �麖a�嶤k
     BSD 2-Clause License

VERSION
    0.08

</pre></body></html>