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.