Perl is actually a very strongly typed language; the issue is that those types are scalar, array, and hash (plus some other fun ones that generally stay in the background). Scalars are essentially all strings with a bunch of magic around numerical data content (again, simplification). I think we've got a bit of an
XY Problem - I think what you really want to know is how to heavily optimize some mathematical operations.
First, profile your code. Make sure the slow chunks really are where you think they are. I like Devel::NYTProf, particularly with its nytprofhtml utility. It makes drilling though profiles fast and easy.
Second, assuming the math is the slow part, I can think of two fairly easy solutions:
PDL. From the docs:
PDL is the Perl Data Language, a perl extension that is designed for scientific and bulk numeric data processing and display.
I haven't used it, but depending on the math you want to do, it's probably the lowest overhead dive to get good performance.
Inline::C. In this case, I have used it, and I like it a lot. However, it will require that you program in C in order to do your fast operations. It buys you ease in terms of getting the Perl code to call C.
You can't get something for nothing, but if you are doing heavy numerics in Perl, there is almost assuredly opportunity for growth.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
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.