CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
process series of data

 



mohtasunil
New User

Jul 20, 2011, 8:53 PM

Post #1 of 1 (611 views)
process series of data Can't Post

Hello guys ..

I want to process a output from a device through a subroutine
these are repeated in every 15 mins ..

i quoted which data i want in first sample by script .. ,


START OF PROCESSING DATE: 20/07/2011 18:45:00
"70" VALID OBJECT
"NCTT" 12
NCH3 11
NCSI 0
"NCIU" 0
NCIS 1
"NTH3" 8
NTSI 0
NFH3 0
"NFSI" 0
NAH3 0
NASI 0
NNCC 6
NRIM 0
NRTF 0
NRRU 0
NRSC 0
NROO 0
NRSA 0

71 VALID OBJECT
NCTT 13
NCH3 12
NCSI 0
NCIU 0
NCIS 1
NTH3 10
NTSI 0
NFH3 0
NFSI 0
NAH3 0
NASI 0
NNCC 10
NRIM 0
NRTF 0
NRRU 0
NRSC 0
NROO 0
NRSA 0

75 VALID OBJECT
NCTT 96
NCH3 63
NCSI 0
NCIU 0
NCIS 33
NTH3 81
NTSI 0
NFH3 0
NFSI 0
NAH3 0
NASI 0
NNCC 84
NRIM 0
NRTF 0
NRRU 0
NRSC 0
NROO 0
NRSA 0

END OF PROCESSING DATE: "20/07/2011 19:00:00"


#should be sent with parameters cmd_output , Valid object regex,Parameters array, current device oms, tablename,database connections




Code
 
sub update_param_into_db_with_parsing {
my @sub_output = @{$_[0]};
my $sub_regex = $_[1]; # should be a valid regex to match valid obj
my @param_list = @{$_[2]};
my $param_obj = shift @param_list;
my $CURRENT_OMS = $_[3];
my $sub_TABLEname = $_[4];
my $sub_dbh = $_[5];
my %DATA;
my %OBJ_HASH;
my %obj_list;
my $TIME_STAMP;
my $OBJ_NAME;
my $param;
my @sub_output;
my $sub_regex;
my @param_list;
my $param_obj;
my $CURRENT_OMS;
my $sub_TABLEname;
my $sub_dbh;


foreach (@sub_output){
chomp;
if (/^START OF PROCESSING DATE:\s(.*)$/){
print "inside start of processing\n";
undef %OBJ_HASH;
$TIME_STAMP = timeFormat($1,'-');
print "formatted sample date: $TIME_STAMP\n" if $DEBUG;
# Get the object fist
}elsif (/^($sub_regex)\sVALID OBJECT$/) {
$obj_list{$1} = 1;
$OBJ_NAME = $1;
$OBJ_HASH{$OBJ_NAME}{$param_obj} = $1;
print "current Trk: $1\n" if $DEBUG;
#list of paramters now
} elsif (/^$param\s*([0-9]*\.?[0-9]*)/){
$OBJ_HASH{$OBJ_NAME}{$param} = $1;
print "New $param: $1 for $OBJ_NAME at $TIME_STAMP \n" if $DEBUG;
} ##### i am stuck at this place ..


elsif (/\s*END\s+OF\s+PROCESSING\s+DATE\:\s(.*)$/) {
print "in side End of processing\n";
$TIME_STAMP = timeFormat($1,'-');
undef %DATA;
foreach $OBJ_NAME (keys %OBJ_HASH) {
for $param (@param_list){
$DATA{OMS_IP} = $CURRENT_OMS;
$DATA{OBJ_NAME} = $OBJ_HASH{$OBJ_NAME}{$param};
$DATA{TIME_STAMP} = $TIME_STAMP;
print "current trunk : $DATA{OBJ_NAME}\n";
INSERT_DATA_IN_TABLE(\%DATA, $sub_TABLEname , $sub_dbh); # this is putting all hash data in database
}
}
}
}
}



can you help me which type of loop structure i should use ..
let me know if you need more info ..

Bregds/SM

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives