arunbear suggested an example if how IO::All is helpful might be good. So here is one contrived example of making a copy of a file with the text reversed in a cross-patform manner (all code is untested):

without IO:All:

use File::Spec; my $file = File::Spec->catfile('my','dir','my_file.txt'); open (MYFILE, '<', $file) or die "Can't open $file: $!\n"; my @lines = <MYFILE>; close MYFILE; my $rfile = File::Spec->catfile('my','dir','reversed.txt'); open(RFILE, '>', $rfile) or die "Can't open $rfile: $!\n"; print RFILE reverse @lines; close RFILE;
With IO::All:
use IO::All; io->catdir('my','dir','my_file.txt')->backwards > io->catdir('my','dir','reversed.txt');
To my mind the best thing about IO:All is that it takes care of all the error checking related to IO operations as well is the fussiness of opening and closing files in the correct mode for the desired operations.

There are a number of other examples of how this module can be used to make your code simpler and more straightforward in the documentation that comes with IO::All.

update: I misspoke in the opening paragaraph. This example reverses the lines in the file, the whole text is not reversed.

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."


In reply to Re: IO::All is sliced bread by DrWhy
in thread IO::All is sliced bread by DrWhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.