Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Put (almost) everything in modules. This makes testing easy, but requires more exposure of subs than I want

I don't understand that point at all; maybe your definition of "exposure" is different than mine.

In Perl, every named subroutine can in principle be called from the outside, independently if it is defined in a script file or a module. (a script can do another script, and then access that second script's subs)

By convention, subs starting with an underscore are consider "private", so if you want to reduce exposure of a sub inside a module, simply mark it with an underscore.

as well as more linkages between modules

I don't see that as a problem either. You can write

# # do stuff 1 here

Or you can write

# use Module::That::Does::What::I::Want qw/doit/; doit(@ARGV); # file Module/That/does/What/I/ package Module::That::Does::What::I::Want; sub doit { # do stuff 1 here }

And have just one more level of indirection, but an easier time to test all the other subroutines from the module without running doit.

Of course that approach isn't very different from writing all the code in the script, no code in the mainline, and at the end of the script putting a

doit(@ARGV) unless caller;

That way you can also load the script as do '' without executing sub doit.

In reply to Re: TDD of non-module code by moritz
in thread TDD of non-module code by davies

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (11)
    As of 2020-12-01 15:28 GMT
    Find Nodes?
      Voting Booth?
      How often do you use taint mode?

      Results (11 votes). Check out past polls.