halligalli has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have some problems to handle datasets.... The first line of "@data" contain the different parameter (seperated by Tab) like: Size (cm) Date (yyyy-mm-dd) Temperature (°F) and below I have the corresponding values. The parameter variies from dataset to dataset so I would like to automatically identify the different parameter and the corresponding values below that I could work with it. Finally I would like to have in $Temperature all the Temperature values...and so on.... I have no clue how to do it.....

Replies are listed 'Best First'.
Re: combine parameter row with data
by Anonymous Monk on Jul 21, 2010 at 12:10 UTC
    I have no clue how to do it.....

    Break it up into pieces, write down steps, convert that into code

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: combine parameter row with data
by roboticus (Chancellor) on Jul 21, 2010 at 15:06 UTC

    halligalli:

    If you use DBI, then you can get the names and data types of the columns of a result set, and write the appropriate code to manipulate the data. For example, if you're writing a spreadsheet, you can find out if a column is varchar, float, date, or whatever, and use the correct Spreadsheet::WriteExcel write function to ensure that the data looks like you want it to.

    Since your question lacks so many specifics, it's hard for me to give a better answer than that. Read the DBI docs, and give it a try. If you have any further questions after that, let us know...

    ...roboticus

      thanks for the answers. I will work on it and specify my questions.....
Re: combine parameter row with data
by Gangabass (Vicar) on Jul 21, 2010 at 12:52 UTC

    May be you have headers in the first line than you can use this info to find which type of data each column have.

Re: combine parameter row with data
by Jenda (Abbot) on Jul 24, 2010 at 17:07 UTC

    split() the first element (not line) into an array, build a hash using the elements of the array as keys and their positions as values and then split() the following elements and access the values you are interested in using the index you obtain by using the hash you built from the first element.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.