I like code that I can see exactly what is going on without going back and forth in the lines of code. Especially when a script becomes gargantuan. In your first case:
would be my preferred style. I could also go with:my %tests = map { $_ => 0 ) qw/ tfred tjock tfortytwo / ;
as long as those two lines are next to each other in the code. Passing a reference to a hash to subs later on is more readable to my eyes that something like:my $tests ={}; map { $tests -> { $_ } = 0 } qw/ tfred tjock tfortytwo /;
but that is a personal preference.callToSub(\%tests);
In your second case I am a big fan of
kinds of things. (Line right out of one of my projects). The term OK is the result of a stack of use constant OK =>0; sorts of things where I use constants to aid in my code's readability.my $errstr = ( $case != OK ? $msg[$case] : "" );
In reply to Re: Two simple code style advice questions
by blue_cowdawg
in thread Two simple code style advice questions
by eyepopslikeamosquito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |