in reply to regarding Tie::File

Below is my code:

That code doesn't have 42 lines. Thus the error is coming from another program. As we can't see it, we can only guess as to what it might be.

As a side note, why are you using fork? Do you have a multiprocessor machine? Your single file is probably on a single hard drive and almost definitely on a single hard drive controller. Your bottleneck here is IO. As your algorithm doesn't support the overlap of lines, you can't even benefit from any OS-level caching.

I'm also not sure that Tie::File is fork safe. It might be. I don't know.

Replies are listed 'Best First'.
Re^2: regarding Tie::File
by xiaoyafeng (Deacon) on Jan 13, 2007 at 02:06 UTC
    Thanks for your reply.In fact,the script is going to run on two processor TRU64 machine, and the size of the file i want to search is over 500M.So I thought that using fork might speed up my search.

    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
      I thought that using fork might speed up my search.

      It's pretty unlikely, as it is. Can you split the file into two pieces and put each on separate hard drives with separate controllers? That's more likely to help. (It's not easy to say for sure. There's some black magic with regard to performance optimization. It's absolutely necessary to identify the single most likely bottleneck, though. That's IO here, as it usually is, and having only one file means that that's the most likely place for the bottleneck to start.)

      If your actual code is about as simple as that which you posted, GNU grep might be more useful; see the -n option.

Re^2: regarding Tie::File
by xiaoyafeng (Deacon) on Jan 13, 2007 at 02:34 UTC
    And What does "That code doesn't have 42 lines" mean? It will lead to unpredictable result?


    Update: correct grammar mistake as ww mentioned.
    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

      Your warning message was "Use of uninitialized value in pattern match (m//) at serarch_file.pl line 42, ..." This means the warning came from a script with at least 42 lines of code in it. Yours didn't therefore whatever script quoted wasn't what produced the warning.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊