CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions:
Contolling lib behavior using environment variables

 



gknopp
New User

Feb 21, 2007, 1:17 PM

Post #1 of 3 (4112 views)
Contolling lib behavior using environment variables Can't Post

I'll looking for folks opinion on whether the behavior of a module used in a script should ever be indirectly contolled using environment variables and not by the script itself.

I contend this is bad design and that all parameters whether they're retrieved from the enviroment or set on the command line should always pass through the script, where upon the script tells the modules what parameters settings to use.

Other folks contend that this requires more coding and maintenance at the script level. They believe that controlling behavior at the module level promotes better code reuse and thus a better design.

What's your opinion?


ProBulletin
Novice

Feb 23, 2007, 9:31 AM

Post #2 of 3 (4104 views)
Re: [gknopp] Contolling lib behavior using environment variables [In reply to] Can't Post

Could you give an example?


Regards,
Paul Wilson
ProBulletin Board: http://www.probulletin.com/


gknopp
New User

Feb 23, 2007, 10:23 AM

Post #3 of 3 (4102 views)
Re: [ProBulletin] Contolling lib behavior using environment variables [In reply to] Can't Post

One piece of information that I failed to include in my mail message was that these scripts are used to test a product.

> ./test.pl x=10

Sol'n 1
--------------------------
===test.pl===
...
$x=get_param("x");
$mylib_obj->myfunc(x=>$x);
...

===mylib.pm===
...
sub myfunc {
my($self,$x)=@_;
...
}

OR

Sol'n 2
---------------------
===test.pl===
...
$mylib_obj->myfunc();
...


===mylib===
...
$x=get_param("x");
sub myfunc {
my ($self)=@_;
...
}

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives