in reply to Opening files in a loop

@data = <FH>;

The line of code I quoted overwrites the contents of @data each time through the loop. You can open as many files as you like, but the code only ever stores the lines from the last file you read.

A quick fix might be to replace that with push @data, <FH>;.

As a side note, you can loop over the contents of an array without an index with:

for my $name (@data_names) { # open files here }

Replies are listed 'Best First'.
Re^2: Opening files in a loop
by loop362 (Pilgrim) on Jun 04, 2005 at 02:24 UTC
    Aloha,

    Yes your right. In fact how I have made progress was to reuse code, because reused code is proven. This was a time I strayed, (forgot I'm still a beginner). Thanks a lot for the help.

    Mahalo jwg