in reply to Prepend Evey Line in a File
Loading 20MB in the memory will speed up the things, but there are some problems related with that:
Anyway, do not use REGEX to prepend the variable there. REGEX is a cool thing, but is a mistake to use REGEX as the solution for everything. In your case, a very simple print will do, so I using REGEX?
As a hint, try to use print like this:
print $prepend_value, $line_from_file, "\n";Instead of:
print "$prepend_value$line_from_file\n";Usually using print with multiple arguments is faster them concatenating strings and print after that. Use Benchmark to test the speed of different methods.
|
|---|