Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sorting measurements

by anonymized user 468275 (Curate)
on Aug 19, 2015 at 09:27 UTC ( [id://1139155]=note: print w/replies, xml ) Need Help??


in reply to Sorting measurements

Hi Jenny, To terminate a line of output and start the next line, you print "\n". In this case you only want to do that when the tries are exhausted and otherwise a tab or space separator. e.g.:
for (my $i = 0; $i <= $#MeasurementType; $i++) { my $toTry = $MeasurementTry[$i]; while ($toTry) { print "$MeasurementType[$i] " . "-- " . "$MeasurementDate[$i], " . "Oops "; print --$toTry ? "\t" : "\n"; } }
I put "Oops" instead of the measurement value because I am presuming there are different values per try, otherwise more than one try would be redundant, but you have only one value per measurement type. Perhaps you need an array of array for the values as another poster has suggested. If so, you'll also need to index through them per inner loop.

The last print statement I put in may seem harder to read -- it's a shorthand for the following logic: "decrement $toTry, then print tab if there are still tries left else print cr" - You'll probably have to change that anyway when you re-organise the values array.

One world, one people

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1139155]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-03-28 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found