[svn:parrot] r46224 - trunk/tools/docs

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Sun May 2 23:47:33 UTC 2010


Author: jkeenan
Date: Sun May  2 23:47:33 2010
New Revision: 46224
URL: https://trac.parrot.org/parrot/changeset/46224

Log:
[codingstd] Parrot coding standards, FBOW, tell us to avoid global filehandles
and the 2-argument form of 'open'.  Correcting this file.  This file still
fails to pass perlcritic.t due to subroutine prototypes, but I don't yet know
enough about what this file does to eliminate them myself.

Modified:
   trunk/tools/docs/filename_and_chapter.pl

Modified: trunk/tools/docs/filename_and_chapter.pl
==============================================================================
--- trunk/tools/docs/filename_and_chapter.pl	Sun May  2 23:38:25 2010	(r46223)
+++ trunk/tools/docs/filename_and_chapter.pl	Sun May  2 23:47:33 2010	(r46224)
@@ -43,9 +43,9 @@
 }
 
 
-open( TEX_FH, '>build/parrot-book.tex');
+open my $TEX_FH, '>', 'build/parrot-book.tex');
 
-print TEX_FH <<'HEADER';
+print $TEX_FH <<'HEADER';
 \documentclass[11pt,a4paper,oneside]{report}
 \usepackage{graphics,graphicx}
 \usepackage{colortbl}
@@ -56,36 +56,36 @@
 
 for ( my $i=0; $i<$lang; $i++ ) {
     my $parser = Pod::PseudoPod::LaTeX->new();
-    $parser->output_fh( *TEX_FH );
+    $parser->output_fh( $TEX_FH );
     $parser->parse_file( "${MOD_BUILD_PATH}$$item_list_ref[$i][0]" );
 }
 
-print TEX_FH <<'FOOTER';
+print $TEX_FH <<'FOOTER';
 \end{document}
 FOOTER
 
-close( TEX_FH );
+close( $TEX_FH );
 
 
 sub write_mod( $ ) {
     my $icnt;
 
-    open( IN_FH, "<$$item_list_ref[$_[0]][0]" ) ||
+    open( my $IN_FH, '<', "$$item_list_ref[$_[0]][0]" ) ||
         die( "$0: can't open $$item_list_ref[$_[0]][0] for reading ($!)\n" );
-    open( OUT_FH, ">${MOD_BUILD_PATH}$$item_list_ref[$_[0]][0]" );
+    open( my $OUT_FH, '>', "${MOD_BUILD_PATH}$$item_list_ref[$_[0]][0]" );
 
     # do the same as: sed -e '4,6c\=head0 $$item_list_ref[$i][1]'
-    while( <IN_FH> ) {
+    while( <$IN_FH> ) {
         if ( $icnt = (4..6) ) {
             if ( $icnt =~ /E0$/ ) {
-                print( OUT_FH "=head0 $$item_list_ref[$_[0]][1]\n");
+                print( $OUT_FH "=head0 $$item_list_ref[$_[0]][1]\n");
             }
         }
-        else { print( OUT_FH ); }
+        else { print( $OUT_FH ); }
     }
 
-    close( IN_FH );
-    close( OUT_FH );
+    close( $IN_FH );
+    close( $OUT_FH );
 }
 
 


More information about the parrot-commits mailing list