in reply to Is there something faster than string concatenation?
...the analogous java code is...my $output = ""; for (1 .. 1000) { $output .= get_long_string(); } print $output;
I would not be surprised however if this perl code behaved as inefficiently as you might expect it to...StringBuffer output = new StringBuffer(); for (1 .. 1000) { output.appends(get_long_string()); } System.out.print(output.toString());
(but i haven't tested it ... perl might optimize it)my $output = ""; for (1 .. 1000) { $output = "" . get_long_string() . $output; } print $output;
|
|---|