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
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.