1 2 3 4 5 6 7 8 9 10 | # function: do_hosts # # purpose: to process every host in the /etc/hosts table and see if it # resolves to a valid IP # # solution: read the list of hosts as keys in a hash, then go through # the list of keys (hosts) and store the IP address for each host as # the value for that key, or undef() if it doesn't resolve properly. # Return a reference to the hash, or undef if the /etc/hosts file was # not accessible. |
1 2 3 4 5 | # function: do_hosts: process every host in the /etc/hosts table and see if it # resolves to a valid IP; return a reference to the hash (key=host, # value=IP or undef), or undef if the /etc/hosts file was not accessible. |
1 2 | # do_hosts: returns a ref to hash of hosts (key=host, value=IP/undef) # from /etc/hosts |
1 2 3 4 | #!/usr/bin/perl -w # whodunit.pl: A script to solve a murder mystery # by joe@shmoe.com $Id: whodunit.pl,v 1.92 2000/08/08 19:08:50 joe Exp $ |
1 2 3 4 | use Data:umper; # for debugging printouts use strict; # be strict - pragma for the interpreter use POSIX; # use the POSIX functions |
1 2 3 4 5 6 | use constant ALPHA => 1; # alpha code use constant BETA => 2; # beta code use constant GAMMA => 3; # gamma code use constant USER => 4; # user ID offset use constant GROUP => 5; # group ID offset use constant DEPT => 6; # dept. ID offset |
1 2 3 4 5 6 | # BEGIN: executed at startup, assigns 'root' to the USER environment variable BEGIN { $ENV{USER} = 'root'; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | $| = 1; # auto-flush the output $Data:umper::Terse = 1; # produce human-readable Data:umper output # define the configuration variables my $config = AppConfig->new(); $config->define( # list of undo commands 'UNDO' => { ARGCOUNT => ARGCOUNT_LIST }, # file to log data 'LOG_FILE' => { ARGCOUNT => ARGCOUNT_ONE }, ); $config->file(whodunit.conf'); # load the whodunit configuration file |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |