General Hint:
You can read your data source linewise and process each queue line and store them temporarily in a data structure.
If you encounter a line which starts with BS:, take the data structure and combine it with the data of the current BS: line and clear the temporary data structure.
Example of work:
#!/usr/bin/perl
# vi:ts=4 sw=4 et:
use strict;
use warnings;
use Data::Dumper qw();
my %result;
my %queue;
while ( my $line = <DATA> ) {
chomp $line;
if ( $line =~ m/^BS:\s+(\S+)/ ) {
$result{$1} = { %queue };
%queue = ();
}
else {
my ( $name, $in_percent, $in_num, $out_percent, $out_num )
= split m{ \(| / | of 1024 \| event | of 1024\)}, $line;
$queue{$name} = {
in_q_per => $in_percent,
in_q_num => $in_num,
out_q_per => $out_percent,
out_q_num => $out_num,
};
}
}
# show resulting structure; it's up to you to go on from here ;o)
print Data::Dumper->Dump( [ \%result ], [ '*result' ] );
__DATA__
AAA_AA1_DDD (0% / 0 of 1024 | event 0% / 0 of 1024)
AAA_AA2_DDD (0% / 0 of 1024 | event 0% / 0 of 1024)
BS: 111_DDD, QE: QQQ_DDD (additionnal QE)
BBB_BB1_DDD (0% / 0 of 1024 | event 0% / 0 of 1024)
BBB_BB2_DDD (0% / 0 of 1024 | event 0% / 0 of 1024)
BS: 222_DDD, QE: QQQ_DDD (additionnal QE)
CCC_CC1_DDD (0% / 0 of 1024 | event 0% / 0 of 1024)
CCC_CC2_DDD (0% / 0 of 1024 | event 0% / 0 of 1024)
BS: 333_DDD, QE: QQQ_DDD (additionnal QE)