Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Plan of Attack.

by linuxer (Deacon)
on Apr 20, 2009 at 17:31 UTC ( #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)


Comment on Re: Plan of Attack.
Select or Download Code
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
Node Status?
node history
Node Type: note [id://758763]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-12-26 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls