in reply to Readdir against large number of files

Even if you know the filename, than on (most) file systems, you'd have to scan the directory entries anyway, as file names are not stored in a way to quickly search for them by name. So I doubt there's much to gain in who you process the directory content.

But you might gain a bit if the files are big. In the worst case, you store the entire content in memory. You could also write the inner loop as:

use Fcntl 'SEEK_SET'; while (<UNMODIFIED>) { if (/STRUC20/) { seek MODIFIED, SEEK_SET, 0 or die; next; } print MODIFIED $_; } truncate MODIFIED, tell MODIFIED or die;
Alternatively, find the start of the line following the last line mentioning STRUC20, then use sysread and syswrite to copy the last part of the file.

And there's no need to use /bin/mv to move the temp. file. rename will do.

Of course, the MOST efficient way doesn't involve Perl at all.