In write_action_file(), reduce the scope of a fd scalar and convert an open call...
authorFabian Keil <fk@fabiankeil.de>
Mon, 22 Nov 2010 10:34:44 +0000 (10:34 +0000)
committerFabian Keil <fk@fabiankeil.de>
Mon, 22 Nov 2010 10:34:44 +0000 (10:34 +0000)
tools/uagen.pl

index 55dc63c..ac64754 100755 (executable)
@@ -3,7 +3,7 @@
 ##############################################################################################
 # uagen (http://www.fabiankeil.de/sourcecode/uagen/)
 #
-# $Id: uagen.pl,v 1.7 2010/10/30 15:57:26 fabiankeil Exp $
+# $Id: uagen.pl,v 1.8 2010/11/22 10:34:28 fabiankeil Exp $
 #
 # Generates a pseudo-random Firefox user agent and writes it into a Privoxy action file
 # and optionally into a Mozilla prefs file. For documentation see 'perldoc uagen(.pl)'.
@@ -257,10 +257,9 @@ sub write_action_file() {
     our $action_injection;
 
     my $action_file_content = '';
-    my $actionfile_fd;
 
     if ($action_injection){
-        open($actionfile_fd, $action_file)
+        open(my $actionfile_fd, "<", $action_file)
             or log_error "Reading action file $action_file failed!";
         while (<$actionfile_fd>) {
             s@(hide-accept-language\{).*?(\})@$1$accept_language$2@;
@@ -275,7 +274,7 @@ sub write_action_file() {
         $action_file_content .= sprintf " +hide-user-agent{%s} \\\n}\n/\n",
             $user_agent;
     }
-    open($actionfile_fd, ">" . $action_file)
+    open(my $actionfile_fd, ">" . $action_file)
       or log_error "Writing action file $action_file failed!";
     print $actionfile_fd $action_file_content;
     close($actionfile_fd);