Jenny1990 has asked for the wisdom of the Perl Monks concerning the following question:
As a Perl-Newbie, I'm currently dealing with a programming problem and would like to hear some tipps of someone more experienced in Perl-programming. I'm trying to sort some measurements which I loaded from some SQL-tables in Perl-lists. There are lists with the following structure:
Requirement: If there are more than one try for a measurement, the different tries should be listed next to each other in the same row.@MeasurementType = (MeasurementA, MeasurementB, Measurement C, Measure +mentB, MeasurementB,..........); @MeasurementValue = ( 1A, 3A , 3A , 2A, 5A, ……); @MeasurementTry= (1 , 1 ,1 , 2 , 3, ….); @MeasurementTime= (DateA, DateB, DateC, DateD, DateE,.....); [ All lists have the same length, since they should be seen together, +as their single elements represent the different measurements e.g..Measurement[0]= @MeasurementType[0],@MeasurementValue[0],@Measur +ementTry[0],@MeasurementDate0] I'm trying to create a list, which creates an output like: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ [Measurement] --[1.Try (MeasurementDate, MeasurementValue]--[2. Try]-- +[3.Try] MeasurementA -- DateA, 1A -- ______-- _______ MeasurementB -- DateB, 3A -- DateD,2A -- DateE,5A MeasurementC -- DateC, 3A -- ______-- _______ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Whats the best way to do this?
Since Perl doesn't support two-dimensional arrays, I would try to connect the seperate lists with an additional list where I save references to them.
Doing so, I can use a "for each" to easily print out all measurements.
Unfortunately, this will only list all measurements underneath each other.
Measurements, which have been done more than one time (see MeasurementB in example) shouldn't be added as multiple rows, but as as 2nd or 3rd try in the same row from the first try.
Anyone of you got an advice how to accomplish this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting measurements
by GrandFather (Saint) on Aug 19, 2015 at 08:26 UTC | |
by AnomalousMonk (Archbishop) on Aug 19, 2015 at 18:57 UTC | |
by BillKSmith (Monsignor) on Aug 19, 2015 at 20:57 UTC | |
|
Re: Sorting measurements
by RichardK (Parson) on Aug 19, 2015 at 11:45 UTC | |
|
Re: Sorting measurements
by 1nickt (Canon) on Aug 19, 2015 at 08:57 UTC | |
|
Re: Sorting measurements
by anonymized user 468275 (Curate) on Aug 19, 2015 at 09:27 UTC | |
|
Re: Sorting measurements
by james28909 (Deacon) on Aug 19, 2015 at 08:42 UTC | |
|
Re: Sorting measurements
by Anonymous Monk on Aug 19, 2015 at 12:15 UTC |