Monks:

I have a large chunk of code where I am doing some heavy mathematical work and I would like to know if there are any options to define what type a variable is in order to avoid alot of the interpreter work with the loose/dynamic variable typing. I know that this is unlikely given it is a very non-Perl way of doing something but in short I would like to tell the interpreter that variable $foo is and will always be an integer for example, so don't bother checking if it is anything else. From my understanding, many operations that may be performed on $foo will check the type of the variable before proceeding, deciding how to do the operation.

Additionally, I know that rewriting in another language (C, C++) where this is available by default would provide these advantages, but this is not a good option given that the rest of the program is in Perl and I'm not a programmer by trade, so a C/C++ rewrite will take much longer than implementing the other solution if available. Additionally, it likely won't be a huge benefit in performance but now I'm more interested out of curiosity than anything else.

Thanks in advance for any thoughts on this. As a biochemist without a formal programming background, the PerlMonks site has been a great resource to me in the last few years both from answering the questions I have asked and the volume of stuff available from the questions of others


In reply to Anyway to Have Strong-Like Typing by jmmitc06

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.