Basically, i wanted to make a big hash lookup or if that didnt work a big if elsif elsif ... else structure. I had to use contents of 3 different arrays to get the the part of the code written!

This is the code as follows.
#!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; my $xls = Spreadsheet::ParseExcel->new(); my $xls_book = $xls->Parse( 'chrocordinates.xls' ); my $xls_worksheet = $xls_book->{Worksheet}[0]; my @contigs = map { $xls_worksheet->Cell( $_ , 0 )->Value} 0 .. 1394 ; my @coordinates = map {$xls_worksheet->Cell($_, 1)->Value} 0 .. 1394 ; my @chromosomes = map { $xls_worksheet->Cell($_ , 2)->Value} 0 .. 1394 + ;my $new_contig; my $new_coordinate; my $new_chromosome; foreach my $contig(@contigs){ do{ $new_chromosome = shift (@chromosomes); $new_coordinate = shift (@coordinates); $new_contig = shift (@contigs); print "$new_coordinate => (chromosome => \'$new_chromosome\', cont +ig => \'$new_contig\')\n"; print "elsif \(\$number < $new_coordinate\) {\n"; print "\t"; print "print \"contig \\\'$new_contig\\\', chromosome \\\'$new_chr +omosome\\\'\"\;\n\t}"; } }

the output can be used directly into another program, as code !

All the comments are welcome
Sameet

Replies are listed 'Best First'.
Re: let the program write a program for you
by Anonymous Monk on May 05, 2004 at 12:51 UTC
    I had to use contents of 3 different arrays to get the the part of the code written!
    Why, that's nothing! Back in my day we had to use the contents of 5 arrays, all before breakfast! Then we had to carry the horse up to the mill to start work!
      Actually, i have given it only as an example.
      Sameet
Re: let the program write a program for you
by Anonymous Monk on May 05, 2004 at 16:29 UTC
    I think it is a good idea, if that can save some time!
Re: let the program write a program for you
by CharlesClarkson (Curate) on May 15, 2004 at 04:58 UTC

    Do you have an example of what would be in the spreadsheet? I assume it has something to do with biology, but I don't know the format to create a test sheet.

    HTH,
    Charles
      Hi,
      Sorry for being late! My excel sheet actually has data for the different contigs, their length, lengths of the 'Gap' that seperate each contig. Length of the chromosome and so on. My main program can create a random number and back calculate which chromosome and which contig on the chromosome that number will be long to, if we assume that entire human genome is a single gaint chromosome!

      If you have anyother doubts please feel free to ask!
      Sameet