diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-01-24 17:13:39 +1100 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-01-26 16:10:09 -0800 |
commit | 2c21014b15e853c6832cf2b54408e19757921393 (patch) | |
tree | 3f49327ab811e7a963cf0a978f08c705972bbd67 /scripts | |
parent | daceffa1505f7a74bd16b0a939d2c6dfd862a859 (diff) | |
download | vyatta-cfg-2c21014b15e853c6832cf2b54408e19757921393.tar.gz vyatta-cfg-2c21014b15e853c6832cf2b54408e19757921393.zip |
save_config: fix perlcritic warnings
Use three arg form of open etc.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-save-config.pl | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl index dd53d51..79cda88 100755 --- a/scripts/vyatta-save-config.pl +++ b/scripts/vyatta-save-config.pl @@ -66,28 +66,24 @@ if ($mode eq 'local' and !($save_file =~ /^\//)) { my $version_str = `/opt/vyatta/sbin/vyatta_current_conf_ver.pl`; print "Saving configuration to '$save_file'...\n"; +my $save; if ($mode eq 'local') { - # this overwrites the file if it exists. we could create a backup first. - if (! open(SAVE, ">$save_file")) { - print "Cannot open file '$save_file': $!\n"; - exit 1; - } + # this overwrites the file if it exists. we could create a backup first. + open $save, '>', $save_file + or die "Can not open file '$save_file': $!\n"; } elsif ($mode eq 'url') { - if (! -f '/usr/bin/curl') { - print "Package [curl] not installed\n"; - exit 1; - } - if (! open(SAVE, ">$url_tmp_file")) { - print "Cannot open file '$url_tmp_file': $!\n"; - exit 1; - } + die "Package [curl] not installed\n" unless ( -f '/usr/bin/curl'); + + open $save, '>', $url_tmp_file + or die "Cannot open file '$url_tmp_file': $!\n"; } -select SAVE; +select $save; set_show_all(1); outputActiveConfig(); print $version_str; -close SAVE; +close $save; + select STDOUT; if ($mode eq 'url') { |