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:

  1. Do you have that much of memory available to your application?
  2. Do you need this speed improvement?
  3. Do your application runs in batch mode? Or it's used thru user interaction?

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.

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill