What is more efficient, PM or scripts?
A: Depends!

The primary objective of a PM is to make a module/class that can be reused easy/fast in many different ways, with different applications. And a script is made just to work in some situation.

But is possible to make a PM that works fast too, you just need to make a good work. The advantage of the module is to make it in a architecture better than scripts, since you project it to be used in many ways. The best way to make reusable codes is with Object-Oriented Classes, take a look at perlmodlib, that enable the multi use of your code, since you can make each object of your PM independent of the other.

About speed improvement, you will read a lot of peoples saying that OO is slower, since paste the object reference is slower than normal variables. But in the end you will see that speed is really lost in point that are runned a lot, specially loops, in your code, or when you are working with the memory/HD, and not in the OO point. The best way to make a fast code is to know what hapens in the interpreter and try to use better ways, but never forget the maintenance of your code!

Soo, here are some nodes about speed improvement:

  • How Perl Optimize your code & some code TIPS ;-P
  • Memory usage and perl
  • And don't forget:

  • www.perldoc.com
  • But first you need to learn how to write nice PM, and than spend time with deep speed improvement. One good tip is to always use strict in the top of your code, at least for variables. And in the end you can use XS, that can bring another world for you, not only fast codes in C. ;-P

    Graciliano M. P.
    "The creativity is the expression of the liberty".


    In reply to Re: Module Efficiency by gmpassos
    in thread Module Efficiency by Coplan

    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.