pf-tools commit: r894 [parmelan-guest] - in /branches/next-gen: README.coding.style filters/filter_privateresolve

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Tue Sep 7 21:50:23 UTC 2010


Author: parmelan-guest
Date: Tue Sep  7 21:50:22 2010
New Revision: 894

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=894
Log:
filter_privateresolve: IO::File

Modified:
    branches/next-gen/README.coding.style
    branches/next-gen/filters/filter_privateresolve   (contents, props changed)

Modified: branches/next-gen/README.coding.style
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/README.coding.style?rev=894&op=diff
==============================================================================
--- branches/next-gen/README.coding.style (original)
+++ branches/next-gen/README.coding.style Tue Sep  7 21:50:22 2010
@@ -17,6 +17,8 @@
 * Always use a bare "return;" on failure. Always return a true value on
   success (but not necessarily 1).
 
+* Always use IO::File objects instead of a bare open().
+
 
 The following line is only here to tell Vim my preferences when editing this
 file :

Modified: branches/next-gen/filters/filter_privateresolve
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/filters/filter_privateresolve?rev=894&op=diff
==============================================================================
--- branches/next-gen/filters/filter_privateresolve (original)
+++ branches/next-gen/filters/filter_privateresolve Tue Sep  7 21:50:22 2010
@@ -25,6 +25,7 @@
 use warnings;
 
 use English qw( -no_match_vars );    # Avoids regex performance penalty
+use IO::File;
 use Getopt::Long qw( :config ignore_case_always bundling );
 use Sys::Hostname;
 
@@ -124,7 +125,8 @@
     }
 }
 
-$ZONE = Get_zone_from_site_GLOBAL( $SITE, $GLOBAL_STRUCT ) if ( $ZONE eq '' );
+$ZONE = Get_zone_from_site_GLOBAL( $SITE, $GLOBAL_STRUCT )
+    if $ZONE eq '';
 
 if ( $INPUT_FILE eq '' || $OUTPUT_FILE eq '' ) {
     Abort( $CODE->{'UNDEF_KEY'},
@@ -135,12 +137,16 @@
     = Search_and_replace( $HOSTNAME, $SITE, $INPUT_FILE, 'resolver',
     $PF_CONFIG, $SEPARATOR, $GLOBAL_STRUCT, $TYPE_RESOLVE );
 
-unless ( open( OUTPUT, ">" . $OUTPUT_FILE ) ) {
-    Abort( $CODE->{'OPEN'},
-        "Unable to open destination file " . $OUTPUT_FILE . " : $OS_ERROR" );
-}
+my $output_fh = IO::File->new("> $OUTPUT_FILE")
+    or Abort( $CODE->{'OPEN'},
+        "Unable to open destination file $OUTPUT_FILE: $OS_ERROR" );
 
-print OUTPUT join( "", @{$filtered_src} );
-close(OUTPUT);
+$output_fh->print( join '', @{$filtered_src} )
+    or Abort( $CODE->{'OPEN'},
+        "Unable to write to destination file $OUTPUT_FILE: $OS_ERROR" );
+
+$output_fh->close()
+    or Abort( $CODE->{'OPEN'},
+        "Unable to close destination file $OUTPUT_FILE: $OS_ERROR" );
 
 exit 0;




More information about the pf-tools-commits mailing list