die "Usage: permmy -[itcad] [directory] -f config-file\n" unless @ARGV >= 3; use vars qw/ $opt_t $opt_c $opt_d $opt_i $opt_f $opt_a/; getopts('tcdi:f:a:') or die "Usable options are -tcifa: $!\n"; #### sub usage { my $text = <## if ($opt_t || $opt_d || $opt_c) { ... } [ snip 11 subroutines covering some 180 lines ] if ($opt_d) { ... } #### exit 0; # --- subroutines #### if ($opt_d) { configtest(); } elsif ($opt_i) { configurator("i", $perms_config_file, $dir_tree, \&wanted_ia); } elsif ($opt_a) { configurator("a", $perms_config_file, $add_tree, \&wanted_ia); } elsif ($opt_t) { configtest(); fulltest(); } elsif ($opt_c) { configtest(); changeperms(); # or whatever this actually does } #### if (valid($foo)) { ... } #### if ($obj->valid) { ... } #### validate($foo); # dies if invalid #### sub configurator ($$$$) { ... exit; close CONFIG or die "Could not close config file $conf_file: $!\n"; } #### my $nice_mode = &return_mode($mode); #### sub change_mode ($$) { ...(oct($change_value) != oct($c_nice_mode))... } #### chown($num_uid, -1, $the_file) or warn "Could not change owner of $the_file: $!\n"; print "Changed owner of $the_file from $c_pwuid to $change_value\n"; #### if (chown(...)) { print "success"; } else { warn "failure"; } #### chown(...) or do { warn "failure"; return }; print ... #### if ($testy eq "dir-mode") { $d_mode = $config{$test}{$tester}{$testy} } elsif ($testy eq "file-mode") { $f_mode = $config{$test}{$tester}{$testy} } ... #### elsif ((-d $_) && ($d_uid))