in reply to Re: Re: CGI and why?
in thread CGI and why?
Not everyone uses a glass TTY or emulates it with a fixed-width font.
No, but many of us do. It's the least common denominator. If you want your code to be maintainable regardless of the environment preferred by the maintainer, you really should keep it in mind.
Even most of those who don't constrain themselves to a proper 80 character line use fixed-width fonts. Even most lame editors that come embedded in the plethora of available "integrated development environments" at least default to a fixed width font. How many nodes here are considered because code tags weren't used and the result is almost unreadable even when BR tags are inserted? What font do you use?
I strongly stand by my statement that the assignment operators should be lined up. It doesn't take much more work (even when you have to change a bunch of them) and it is worth it to give your code a polished look.
I think that the code
is simply more readable asmy $foo = 'bar'; my $bazqux = 42; my $quux = "$bazqux ${foo}s"; my $money = 'gold'; my $total_fortune = $quux . "of $money\n";
and if you actually disagree, well, you are welcome to your opinion on the matter (right up until the day you do any work for me, that is.)my $foo = 'bar'; my $bazqux = 42; my $quux = "$bazqux ${foo}s"; my $money = 'gold'; my $total_fortune = $quux . "of $money\n";
As for the example, I'd rather use a slice rather than mentioning the params array on every line.
In the example, the multiple assignments were separate calls to the param() method of the CGI object called $q, not assignment to several elements at different keys in the same hash. If it was the latter, I probably wouldn't recommend assigning to scalars at all. If it really made sense though, I'd be inclined to agree that a hash slice would be the way to go.... maybe. Even that might be a lot less maintainable if there were many variables. Consider:
versusmy ($foo, $bar,..., $baz,... $qux) = @hash{'abc', 'def',..., 'pqr',... + 'yz'};
The more verbose method neatly puts each variable on the same line as its hash element. If you had to change the assignment to $baz in the former of those two methods, you'd find yourself counting keys in your slice to find the one it matched with. That's a pretty ugly situation.my $foo = $hash{abc}; my $bar = $hash{def}; . . . my $baz = $hash{pqr}; . . . my qux = $hash{yz};
I don't know if the accessor function has something similar. That is, if passed multiple arguments will it return a list as well?
No. Calling it with multiple arguments, as in
will result in the parameter 'foo' being assigned an array with the values 'bar' and 'baz' in it. It's the same as calling it as$q->param('foo','bar','baz')
$q->param(-name => 'foo', -values => ['bar', 'baz'])
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: CGI and why?
by John M. Dlugosz (Monsignor) on Jan 01, 2003 at 09:55 UTC | |
by sauoq (Abbot) on Jan 01, 2003 at 21:30 UTC |