Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I pass common arguments to Perl modules?
    primarykey
    data
    text
    <p>I'm not thrilled with the argument-passing architecture I'm evolving for the (many) Perl scripts that have been developed for some scripts that call various Hadoop MapReduce jobs.</p> <p>There are currently 8 scripts (of the form run_something.pl) that are run from cron. (And more on the way ... we expect anywhere from 1 to 3 more for every function we add to hadoop.) Each of these have about 6 identical command-line parameters, and a couple command line parameters that are similar, all specified with Euclid.</p> <p>The implementations are in a dozen .pm modules. Some of which are common, and others of which are unique....</p> <p>Currently I'm passing the args globally to each module ...</p> <p>Inside run_something.pl I have:</p> <pre><code>set_common_args (%ARGV); set_something_args (%ARGV); </code></pre> <p>And inside Something.pm I have</p> <p>sub set_something_args { (%MYARGS) =@_; }</p> <p>So then I can do </p> <pre><code>if ( $MYARGS{'--needs_more_beer'} ) { $beer++; } </code></pre> <p>I'm seeing that I'm probably going to have additional "common" files that I'll want to pass args to, so I'll have three or four set_xxx_args calls at the top of each run_something.pl, and it just doesn't seem too elegant.</p> <p>On the other hand, it beats passing the whole stupid argument array down the call chain, and choosing and passing individual elements down the call chain is (a) too much work (b) error-prone (c) doesn't buy much.</p> <p>In lots of ways what I'm doing is just object-oriented design without the object-oriented language trappings, and it looks uglier without said trappings, but nonetheless ...</p> <p>Anyone have thoughts or ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload