in reply to Hash/file --> doesn't seem to work

After the first time through, you're at the end of FILE, so the while() is never entered (i.e., it gets EOF right off). Try using seek.

However, it will probably more efficient (if the file is rather small relative to available memory anyway) to load in the data and then iterate over it pre-parsed, than to re-parse the file and each line every time.

Replies are listed 'Best First'.
Re^2: Hash/file --> doesn't seem to work
by perldesire (Scribe) on Jun 10, 2009 at 07:34 UTC

    At first time, when inner loop execution is over the file pointer will be in EOF. so in next time of checking While(<FILE>) this condition will get false. so it wont go inside inner while loop.

    you can do any one of the following :
    1. Before inner loop begins you can open file handle and at the end of inner while loop close the file handle.
    2.In the beginning of the inner while loop you can make the file pointer to point to the beginning of file using 'seek'. perldoc -f seek.