in reply to Numerical Value question
First look at this line:
my $a = qw(0,100); print $a, "\n"; # prints the string '0,100'
You probably mean my @a = (0,100);, or my @a = qw(0 100). The point is that $a is a scalar, and @a is an array. And qw(0,100) is a single item, whereas qw(0 100) is a list of two items.
Next, only open if the file exists... and use a loop.
my $keyword_EVO100 = "${path}Output/$keyword_EVO100"; my $keyword_folder = "${path}Output/${keyword}_${initial}_$i"; foreach my $suffix (0..100) { my $PRIMERMAP = "$keyword_folder/${$keyword}_EVO100/$keyword-T${su +ffix}_PRIMERS_Primerlist.xlsx"; if (! -e $PRIMERMAP) { print "Primer list file is missing. Please make sure file is i +n correct folder!\n"; print "Press <ENTER> to exit.\n"; <>; exit(1); } $my $PRIMERMAP_OPEN = $Excel->Workbooks->Open("$keyword_folder/${k +eyword}_EVO100/$keyword-T${suffix}_PRIMERS_PrimerList.xlsx"); $PRIMERMAP_open->PrintOut; $PRIMERMAP_open->close; }
Also notice how you can use "${varname}other_text", and also that when dealing with file paths in Perl you can almost always substitute \\ with /, even on Windows.
Next ask yourself if you really enjoy hitting caps lock all the time to type your variables. why all the upper cases? Why such long names? (We're all guilty, just making an observation).
Dave
|
|---|