|
Hey Jamie? I started to make a change in web-lib-funcs.pl what would clean up much of what I'm doing, not break anything backwards, and make for much more intuitive code.
For example, in my module's index.cgi, I have this:
&header($text{'module_title'}, "", "", "", "", "", "", $custom_headers);
What I was thinking was to modify sub header{}. Right now you kind of interpolate checking for values passed with generating the headers. What I would do (and have backed off of, since that's really your baby and not mine), is to instead use static variables and render the headers in one shot. At the top of the routine, check to see whether $_[[0]] is a hash or not. If not, use assignments as you have in the past, ie:
my $title = $_[[0]]; my $image = $_[[1]]; my $help = $_[[2]] if($_[[2]]); my $config = $_[[3]] if($_[[3]]);
etc.
if $_[[0]] is a hash however, then we can make for much more readable code. I could do the above like this:
&header({ title => $text{'module_title'}, header => $custom_headers, });
Then in your routine, you assign as such:
my(%config) = $_[[0]]; # for the sake of readability. my $title = $config{title}; my $image = $config{image}; my $help = $config{help} if($config{help});
and so on.
Dunno. The fact that so many nulls have to be passed in order to pass certain options just doesn't seem clean to me. :) This way at a glance you know precisely what is being passed and why, and doesn't break old code either.
|