Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Plan of Attack.

by linuxer (Curate)
on Apr 20, 2009 at 17:31 UTC ( [id://758763]=note: print w/replies, xml ) Need Help??


in reply to Plan of Attack.

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)

Replies are listed 'Best First'.
Re^2: Plan of Attack.
by NothingInCommon (Initiate) on Apr 20, 2009 at 18:40 UTC
    This worked absolutely flawlessly. :) Thank you so much!!

Log In?
Username:
Password:

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

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

    No recent polls found