This code is a simplified example. The real code is much bigger and more complex. And is used for everything from getting data from pipelines (open my $fh, "tar cf - * | gzip -c |";) carrying hundreds of MB of data, to a couple KB of strings. The latter isn't a big deal, the former is. I'm figuring that I'm going to have to perform the copy myself. Not hard to do, but just has to be done. Note that I can't assume anything about the data, so if I want to be efficient (time/memory), I'm going to either have to use sysread or something, or I'm going to have to set $/ to \1024 or something (fixed length read/write, not line-by-line since, as potentially binary data, I don't have any idea what lines are). Not a big deal, but this is what I was using File::Copy for. :-)

I'm just going to rip some of it from File::Copy, and assume the filehandle is good. I do know, however, that the from-handle and the to-filename should not be the same (it would actually be difficult to do), so this should be ok for all but the pathological cases (where someone is simply trying to break something on purpose).

Thanks!


In reply to Re^2: There be dragons (or, perl5.8's open stringref breaks...) by Tanktalus
in thread There be dragons (or, perl5.8's open stringref breaks...) by Tanktalus

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.