* Gross, Stephan ([EMAIL PROTECTED]) [26 Jun 2001 22:16]:
> Why is this style
> if ($x) {
> do this;
> do that;
> }
> typically preferred over
> if ($x)
> {
> do this;
> do that;
> }
> I like the latter example because it's easier to cut and paste the
> braces and everything in between. I also think it looks better. But
> none of the top programmers ever seems to do this.
It's just a style thing. I, personally, tend to do it your second way.
Kernighan and Ritchie ("The C Programming Language") did it the first
way and many programmers learn their style from there.
The GNU coding standards[1] state in the section on formattnig code [2]
that the {} should be on a new line, but they also want it indented a
bit. e.g.
if ($x)
{
do this;
do that;
}
It's all just a matter of taste really. So long as it's legible, it
should be good.
There are two programs, pbeaut and perltidy, that can change these
things. pbeaut[3] hasn't been released yet, so you can't use it.
PerlTidy[4] apparently works quite well. I've not had cause to use it
yet so I only know it by reputation.
[1] http://www.gnu.org/prep/standards_toc.html
[2] http://www.gnu.org/prep/standards_22.html#SEC22
[3] http://www.consultix-inc.com/perl_beautifier.html
[4] http://perltidy.sourceforge.net/
cheers!
--
iain. <http://eh.org/~koschei/>