Assuming the files aren't too big you could have also done this:
UNTESTED
use strict; use warnings; my $data; open(FILE,"<yourfile") || die "oops $!"; { local $/ = undef; $data = <FILE>; } close(FILE); open(FILE2,">file2"); print FILE2 $data; close(FILE2);
I program in Java as well and I can tell you it will nearly always be slower for most things. Note the nearly and most. I'm sure a threaded program in Java would give Perl a run for its money.

However, thats life, thats programming, live with it. Personally I hate these kind of comparisons. People seem to forget theres fast.... and theres fast enough. If you can code a program quickly (3 days say) and its only 10% slower than a program that takes 3 weeks to build then frankly you could build it, run it and go home before the other one is done.

Of course maintainability, scalability and coding standards are all factors and they should be factored into the build times too. Something that in my experience people forget.

Just my little rant :P.

In reply to Re: Java vs. Perl file I/O benchmarks; valid test? by simon.proctor
in thread Java vs. Perl file I/O benchmarks; valid test? by meonkeys

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.