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


In reply to Re: Numerical Value question by davido
in thread Numerical Value question by OGProphet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



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