Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Pulling specific data from a large text file

by tangent (Parson)
on Jun 13, 2014 at 01:27 UTC ( [id://1089755]=note: print w/replies, xml ) Need Help??


in reply to Pulling specific data from a large text file

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"; } }

Replies are listed 'Best First'.
Re^2: Pulling specific data from a large text file
by TStanley (Canon) on Jun 13, 2014 at 15:08 UTC

    After implementing your above suggestions, here is what the file name/index list looks like:

    File: Record Size: Last Record: Data Byte Count: 68256 Index Names: bulkconf_index, bulkcard_index, _deleted_record_index, g +iftname-number-end, giftname-org-key, _deleted_record_index, _deleted +_record_index, card_index, giftcard-hist-key, giftcard-hist-sold-key, + _deleted_record_index, giftbal_index, _deleted_record_index, pr-chec +k-index, _deleted_record_index, card_index, giftdon_number_index, gif +tdon_cat_index, giftdon_location_index, _deleted_record_index, print_ +req_index, _deleted_record_index, _deleted_record_index, ob-key, com_ +index, _deleted_record_index, chg_index1, date_index, store-index, 1, + zip_index, vzip_index, gift-number, gift-date-redeemed, _deleted_rec +ord_index, reasons-index

    It looks like it is collecting all of the index names in the file, but not associating them with a file name. As far as the number in the data byte count field, I can't tell where that is coming from, as none of the numbers match it. The output I am trying to get would ultimately look like:

    dfs01.out File Listing ..list of file names here.. File Name and Index List File: %demoulas_prod#d01>ccdem>files>gift-bulk Record Size: 100 Last Record: 18912 Data Byte Count: 100 Index Names: bulkconf_index, bulkcard_index, _deleted_record_index File: %demoulas_prod#d01>ccdem>files>gift-name Record Size: 177 Last Record: 54756 Data Byte Count: 6022779 Index Names: giftname-number-end, giftname-org-key, _deleted_record_in +dex etc...

    TStanley
    --------
    People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf. -- George Orwell

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1089755]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-20 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found