# HG changeset patch # User Rik # Date 1405700187 25200 # Node ID 714ce8ca71ea298bc6e30b56b2f14f61f1c4cf3c # Parent 3136e3f8e631e122cbd9dc2491cf9c253e7c0819 mkdoc.pl: Tweaks to make code easier to understand for non-Perl experts. * mkdoc.pl: Use label when short-circuiting out of loop with next. Use GNU indendation style for if blocks. Explicitly use variable $_ in foreach loop for those unaware of Perl's default variable. diff -r 3136e3f8e631 -r 714ce8ca71ea scripts/mkdoc.pl --- a/scripts/mkdoc.pl Thu Jul 17 19:51:21 2014 -0700 +++ b/scripts/mkdoc.pl Fri Jul 18 09:16:27 2014 -0700 @@ -40,31 +40,32 @@ __END_OF_MSG__ -foreach my $m_fname (@ARGV) +MFILE: foreach my $m_fname (@ARGV) { if ($m_fname eq "--") - { - $srcdir = getcwd (); - next; - } + { + $srcdir = getcwd (); + next MFILE; + } my $full_fname = File::Spec->catfile ($srcdir, $m_fname); my @paths = File::Spec->splitdir ($full_fname); - next if @paths < 3 - || $paths[-2] eq "private" # skip private directories - || $paths[-1] !~ s/\.m$//i; # skip non m files and remove extension + if (@paths < 3 + || $paths[-2] eq "private" # skip private directories + || $paths[-1] !~ s/\.m$//i) # skip non m-files, and remove extension + { next MFILE; } ## @classes will have @class/method as their function name my $fcn = $paths[-2] =~ m/^@/ ? File::Spec->catfile (@paths[-2, -1]) : $paths[-1]; my @help_txt = gethelp ($fcn, $full_fname); - next unless @help_txt; + next MFILE unless @help_txt; print "\x{1d}$fcn\n"; - print "\@c $fcn " . File::Spec->catfile ("scripts", $m_fname) . "\n"; + print "\@c $fcn ", File::Spec->catfile ("scripts", $m_fname), "\n"; - foreach (@help_txt) + foreach $_ (@help_txt) { my $in_example = (m/\s*\@example\b/ .. m/\s*\@end\s+example\b/); s/^\s+\@/\@/ unless $in_example;