In your first while(<$IN>) loop you run through each line of the file until the end - after that loop $IN is empty. You need to put some check to break out of the first loop once you have the info you require, something like:
while (<$IN>) { if (/(^w.*)/) { push @lsl,$1; } elsif (/^Directories/) { last; } }
In your second while(<$IN>) loop you print out the contents of %Hash for each found line - the first time %Hash will have only one item, the second two and so on. You need to take the print out of that loop. Also, everything is being added to the single @array and to the single @indexes, so the information of all keys will be printed for each key. Here is a different way to do it:
sub GetDFSdata { #... #Get the list of file names and indexes my $name; while(<$IN>){ chomp; next if /^operator/; #...etc. if (m/$start/) { $name = $1; } elsif (m/^record size:\s+\d+/) { $Hash{$name}{'record_size'} = $_; } elsif (m/^last record:\s+\d+/){ $Hash{$name}{'last_record'} = $_; } elsif (m/^data byte count:\s+\d+/) { $Hash{$name}{'data_byte_count'} = $_; } elsif (m/^\s+index name:\s+(\w.*)/) { push(@{ $Hash{$name}{'indexes'} }, $1); } } close $IN; foreach my $key (keys %Hash) { print $OUT "File: $key<BR>\n"; print $OUT "\tRecord Size: $Hash{$key}{'record_size'}<BR>\n"; print $OUT "\tLast Record: $Hash{$key}{'last_record'}<BR>\n"; print $OUT "\tData Byte Count: $Hash{$key}{'data_byte_count'}< +BR>\n"; my $str = join ',', @{ $Hash{$name}{'indexes'} }; print $OUT "Index Names: $str\n"; } }

In reply to Re: Pulling specific data from a large text file by tangent
in thread Pulling specific data from a large text file by TStanley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.