From 158c7151fd6b3541e892a9a8173db2e4cb787de6 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 4 Apr 2012 19:34:55 -0700 Subject: Fix perlcritic warnings in strip migration comments --- scripts/vyatta-strip-migration-comments.pl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-strip-migration-comments.pl b/scripts/vyatta-strip-migration-comments.pl index 6bc6152..21fcc89 100755 --- a/scripts/vyatta-strip-migration-comments.pl +++ b/scripts/vyatta-strip-migration-comments.pl @@ -21,7 +21,7 @@ use strict; use warnings; - +use File::Copy; # Looking for a comment something like this... # @@ -38,15 +38,17 @@ if (!defined $file) { $file = "/opt/vyatta/etc/config/config.boot"; } -print "copying original configuration file to $file.boot.strip-migration-comments-bu\n"; -`cp $file $file.boot.strip-migration-comments-bu`; +my $backup = "$file.boot.strip-migration-comments-bu"; +print "copying original configuration $file to $backup\n"; +cp($file, $backup) + or die "Error! Unable to copy $file to $backup: $!"; -open(MYINPUTFILE, "<$file") +open(my $inputfile, '<', $file) or die "Error! Unable to open file for input \"$file\". $!"; my $contents = ""; my $in_mig_com = 0; -while() { +while(<$inputfile>) { if ($_ =~ /CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW/) { $in_mig_com = 1; } @@ -60,12 +62,12 @@ while() { $contents .= $_; } } -close(MYINPUTFILE); +close($inputfile); -open(MYOUTPUTFILE, ">$file") +open(my $outputfile, '>', $file) or die "Error! Unable to open file for output \"$file\". $!"; -print MYOUTPUTFILE $contents; -close(MYOUTPUTFILE); +print $outputfile $contents; +close($outputfile); print "done\n"; -- cgit v1.2.3