in reply to Rules of Proper Perl Style
but rather, try to make your code self-documenting, and leave the API and verbose explanation for the Pod:# set $foo to 'bar' my $foo = "bar"; # send $foo to this_func() this_func($foo);
my $prog_state = "bar"; execInstructions($prog_state); # and later... =item C<execInstructions($state)> Executes a given set of instructions for a specific state that the pro +gram is in. Blah blah blah.
# radix sort, O(Nk) # "Mastering Algorithms in Perl", Orwant, et. al. my @sorted_names = radixSort(\@names);
# find_missing() uses a binary-tree approach # see IMPLEMENTATION section of Pod for details my $next_ID = find_missing(\@list);
If you pass that one-liner off on a newsgroup or mailing list as a means to print every other line in a file, give the readers the common decency of a brief explanation:perl -pe '$_ x= --$|' FILE
The x operator is the "count" or "repetition" operator. Saying $_ x= $foo means $_ = $_ x $foo -- it's basically string multiplication. And we use --$| here because it's magical; if it's 0, subtracting one makes it -1, which is a true value, and it stores it as 1; then, when we subtract one, it's 0.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(dws)Re: Re: Rules of Proper Perl Style
by dws (Chancellor) on Feb 18, 2001 at 03:43 UTC |