Greetings & Salutations:

Here is my 1st attempt at a Perl program, and I need guidance. I am trying to perform bandwidth analysis using mutiple data files. I am trying to place all the data points for the given sample set size(1st column of the Sample Files) into a singe row; and the columns would be indexed to the data set size. BTW, the second column in the sample file is the sum of all the data points in that line.

Within the code, you will see my feeble attempts to filled the data cube and read it back. Thanks

The desired output given the two example files would be:

3.011583 2.943297 2.940214 2.955738 2.968009 3.083707 2.958022 2.957737 2.982671 2.990788

6.249463 6.118992 6.124449 6.112282 6.133605 6.384345 6.079698 6.073674 6.108037 6.134851

12.254996 12.263543 12.277047 12.291713 12.196748 12.492582 12.137764 12.164201 12.074652 12.107912

24.024475 23.347609 23.463421 23.294582 23.33654224.010324 23.535210 23.562157 23.596123 23.675554

Sample file 1:

8 14.701072 3.011583 2.943297 2.940214 2.955738 2.968009

16 30.561410 6.249463 6.118992 6.124449 6.112282 6.133605

32 60.983738 12.254996 12.263543 12.277047 12.291713 12.196748

64 116.472912 24.024475 23.347609 23.463421 23.294582 23.336542

Sample file 2:

8 14.788687 3.083707 2.958022 2.957737 2.982671 2.990788

16 30.368369 6.384345 6.079698 6.073674 6.108037 6.134851

32 60.373260 12.492582 12.137764 12.164201 12.074652 12.107912

64 117.676048 24.010324 23.535210 23.562157 23.596123 23.675554

#!/usr/bin/perl -w use strict; use v5.10; use List::Util qw(min max sum); my @procBrdNum; my $numProcBrds; my $dataSetCnt; my @minArray = (); my @maxArray = (); my @avgArray = (); my @completeDataPts = (); my $numDataSets; my @dataSetSizes; my (@totalMin, @totalMax, @totalAvg, @totalThroughputArray); open my $ChassisConfigFile, "<ChassisTest.Cfg" or die ("Unable to open + file \n"); #Get slot numbers" while (my $slotLine = <$ChassisConfigFile>) { push(@procBrdNum,$slotLine); } close $ChassisConfigFile; $numProcBrds = @procBrdNum; printf("numProcBrds: $numProcBrds \n"); #Find and store the local minimimum & maximum throughput per board & t +hen the lowest min and max per board for(my $brdCnt = 0 ; $brdCnt < $numProcBrds; $brdCnt++) { my $T = $procBrdNum[$brdCnt] ; $T =~ s/\R//g; #Remove line break - not sure why there is a line + break? my $TestFileName = "Slot". $T ."Simplex.cfg.data"; printf("Board $procBrdNum[$brdCnt] File Name: $TestFileName \n"); + open my $dataFile, "<$TestFileName" or die ("Unable to open file + \n"); $dataSetCnt = 0; while (my $dataLine = <$dataFile>) { $dataLine =~ /^#/ and next; my @dataPts = split(/\s+/, $dataLine); my $dataSetSize = shift(@dataPts); if($brdCnt == 0) { push(@dataSetSizes, $dataSetSize); } my $totalThroughput = shift(@dataPts); my $min = min(@dataPts); my $max = max(@dataPts); my $avg = scalar @dataPts ? (sum(@dataPts) / (scalar @dataPts +)) : 0; push @{ $totalThroughputArray[$dataSetCnt]}, $totalThroughput +; push @{ $minArray[$dataSetCnt]}, $min; push @{ $maxArray[$dataSetCnt]}, $max; push @{ $avgArray[$dataSetCnt]}, $avg; #BAD CODE HERE! #@{ $completeDataPts[$dataSetCnt]} = (@{ $completeDataPts[$da +taSetCnt]}, @dataPts); #push @{ $completeDataPts[$dataSetCnt]}, @dataPts; my $completeDataPtRef = \@{ $completeDataPts[$dataSetCnt]}; push @{ $completeDataPtRef}, @dataPts; $dataSetCnt++; } } $numDataSets = @dataSetSizes; #MORE BAD CODE HERE! #for(my $dataSetCnt = 0; $dataSetCnt < $numDataSets; $dataSetCnt++) my $completeDataPtRef = \@{ $completeDataPts[$dataSetCnt]}; my $numCmpDataPts = @$completeDataPtRef; print "CmpDataPts $numCmpDataPts \n"; print "@$completeDataPtRef \n"; #{ # print " @{ $completeDataPts[$dataSetCnt]} \n"; # my @oneLineDataPts = (); # push @oneLineDataPts,[@{ $completeDataPts[$dataSetCnt]}]; #my $numCmpDataPts = @{ $completeDataPts[$dataSetCnt]}; #printf("Num of data Sets $numCmpDataPts \n"); #my @oneLineDataPts = { $completeDataPts[$dataSetCnt]}; #my $numOneLinePts = @oneLineDataPts; #printf("Num of data Pts $numOneLinePts \n"); # for(my $ptCnt = 0 ; $ptCnt < $numOneLinePts; $ptCnt++) # { # printf("DataValuesData Set Ct: $dataSetCnt, dataPt[ $ptCnt ] + = $oneLineDataPts[$ptCnt] \n"); # } #}

In reply to Appending arrays into the rows of a 2 dimension array by SoftwareGoddess

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.