in reply to Appropriate application of readline

You would probably be best to use a hash where the key is the broker you find and the values is the data. Here is an example:

#!/usr/bin/perl -w use strict; my (%brokers, $broker); # get file contents into an array for convenience open (CONFIG, "ubroker.properties") || die "Can't Open ubroker file: $ +!"; while (<CONFIG>) { next if /^#/; chomp; $broker = $_ if /^\[.*\]$/; # found a broker $broker = '' if /^\s*$/; # found a blank line # add line to current $broker if there is one $brokers{$broker} .= "$_\n" if $broker; } close CONFIG; # keys %brokers returns an array of brokers to iterate over for (keys %brokers) { print "\nBroker: $_\n"; # this is the broker name print $brokers{$_}; # this is the data (includes name) }

If you want to do it with a while(<CONFIG>) you either need to do it in one loop (as you will reach the end of the file after the first loop) or use seek CONFIG, 0, 0; to go back to the begining of the file before you do a second while loop through it.

In this example we use a hash to store both the brokers array (as the keys) and the data associated with each broker (as the values) which means that there is a logical link between the data. If you just wanted arrays then:

@brokers = keys %brokers; @data = values %brokers;

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print