diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-01-28 09:02:18 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-01-28 09:02:18 -0800 |
commit | a98ef0110094a6c655e25d21f04dec98f66cdc3f (patch) | |
tree | 43c1258a7524d6eacc6e9aa5b619b7ef5cc996e0 /scripts | |
parent | 040b6c2ba9e072f4b53199ad8d1563986d2f4022 (diff) | |
download | vyatta-cfg-quagga-a98ef0110094a6c655e25d21f04dec98f66cdc3f.tar.gz vyatta-cfg-quagga-a98ef0110094a6c655e25d21f04dec98f66cdc3f.zip |
utils: turn on strict
Turn on strict and fix perlcritic warnings.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vyatta_quagga_utils.pl | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/scripts/vyatta_quagga_utils.pl b/scripts/vyatta_quagga_utils.pl index eaf83649..c0087ea6 100644 --- a/scripts/vyatta_quagga_utils.pl +++ b/scripts/vyatta_quagga_utils.pl @@ -1,62 +1,49 @@ #!/usr/bin/perl +use strict; use lib "/opt/vyatta/share/perl5/"; use Vyatta::Config; use Vyatta::Misc; use NetAddr::IP; use Getopt::Long; -GetOptions("check-prefix-boundry=s" => \$prefix, - "not-exists=s" => \$notexists, - "exists=s" => \$exists, - "check-ospf-area=s" => \$area, +GetOptions("check-prefix-boundry=s" => sub { check_prefix_boundry( $_[1] ); }, + "not-exists=s" => sub { check_not_exists($_[1]); }, + "exists=s" => sub { check_exists($_[1]); }, + "check-ospf-area=s" => sub { check_ospf_area($_[1]); }, ); -if (defined $prefix) { check_prefix_boundry($prefix); } -if (defined $notexists) { check_not_exists($notexists); } -if (defined $exists) { check_exists($exists); } -if (defined $area) { check_ospf_area($area); } - exit 0; -sub check_prefix_boundry() { +sub check_prefix_boundry { my $prefix = shift; my ($net, $network, $cidr); $net = new NetAddr::IP $prefix; $network = $net->network(); $cidr = $net->cidr(); - if ("$cidr" ne "$network") { - print "Your prefix must fall on a natural network boundry. ", - "Did you mean $network?\n"; - exit 1; - } + + die "Your prefix must fall on a natural network boundry. ", + "Did you mean $network?\n" + if ($cidr ne $network); exit 0; } -sub check_exists() { +sub check_exists { my $node = shift; my $config = new Vyatta::Config; - if ( $config->exists("$node") ) { - exit 0; - } - - exit 1; + exit $config->exists($node) ? 0 : 1; } -sub check_not_exists() { +sub check_not_exists { my $node = shift; my $config = new Vyatta::Config; - if (! $config->exists("$node") ) { - exit 0; - } - - exit 1; + exit $config->exists($node) ? 1 : 0; } -sub check_ospf_area() { +sub check_ospf_area { my $area = shift; # @@ -68,7 +55,7 @@ sub check_ospf_area() { } } if ($area =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { - foreach $octet ($1, $2, $3, $4) { + foreach my $octet ($1, $2, $3, $4) { if (($octet < 0) || ($octet > 255)) { exit 1; } } exit 0 |