in reply to File slurping efficiency

Arrays use more memory than scalars, and there will be some processing needed to split up a file into records (one record per slot in the array). However, it does take a bit of time to localize a magic variable and restore it. My suspicion is that method B is faster, but I don't have any benchmarks.

In cases like this, I usually go with whichever method makes parsing easier. If it's line based, I loop over the array (or use while on the filehandle). If I'm dealing with something that can span lines, I'll try the second (or redefine $/).

If you're only looking for the first instance of the string in the file, and you're only concerned with what else is on the line, I'd go with while. Without seeing your data or knowing more about it, it's hard to say more.