
jeffersno1
Novice
May 31, 2012, 12:34 AM
Post #1 of 2
(742 views)
|
|
inserting to hash and calculating !!!!
|
Can't Post
|
|
Hi All, Wondered if someone could me here, I support a data pass system where users purchase a data pass to browse the internet, These passes have an allocated data allowance (ranging from 50MB to 10GB) I'm trying to get the average pass usage for each pass name. Each pass will expire by Volume or Time and the logs look like this: for pass expiry date,passexpiry,Customer number,Pass name,uk_number,AMOUNT OF PASS USED,pass expiry datetime 2012-05-29_00:01:10:353,passExpiryTime,440000000000,PASS00034,UK_8713649,1199045388,2012-05-26_00:01:11 2012-05-29_00:01:11:408,passExpiryTime,440000000000,PASS00030,UK_8733042,58458706,2012-05-28_00:01:12 for pass expiry by volume the logs are different date,Customer number,passexpiry,PASS NAME,uk_number,pass expiry datetime,AMOUNT OF PASS USED 2012-05-29_00:03:52:821,440000000000,passExpiryVolume,PASS00016,UK_8558084,2012-06-10_14:36:02,2147484755 2012-05-29_00:03:59:986,440000000000,passExpiryVolume,PASS00017,UK_8726029,2012-05-30_11:11:10,1073743201 I have all pass info available (name & volume allocated) pass_name vol_allocated_bytes PASS00034 2147483648 PASS00030 10485760 PASS00016 2147483648 PASS00017 10485760 Ideally I'd like to get a print out like: PASS NAME VOL_ALLOCATED AVERAGE_VOL_USED PASS00034 2147483648 1965088868 PASS00030 10485760 10485560 Questions: 1- How do i pass the VOL ALLOCATED to the same array or hash where the pass name and VOL used will be? Here is an attempt!!!
push(@PASS00034 ,"2147483648"); push(@PASS00030,"10485760"); push(@PASS00016,"2147483648"); This is what i have so far
#!/usr/bin/perl -w #use strict; use warnings; my $pass_file = '/export/home/otpuser/pass_expiry'; open my $fh, '<', $pass_file or die "cant open $!\n"; while (my $line = <$fh>) { chomp($line); if (length($line) > 0) { @lineArray=split(",",$line); if ( $lineArray[1] =~ /passExpiryTime/ ) { $resultsHash{$lineArray[3]}=$lineArray[5]; } } } Any suggestions would be greatly appreciated. Thanks Jeffers
|