1 2 3 4 5 6 7 8 9 | print Dumper \%ENV; # print the full ENV hash # get the environment variable names that begin with USER @user_vars = grep(/^USER/, keys %ENV); # print the values in all the variables that begin with USER, using a # hash slice print Dumper @ENV{@user_vars}; print "Done\n"; # print "done" message # TODO: find better method of sorting variables # TODO: use Data:umper with variable names |
1 2 3 4 5 6 | # go through all the numbers between 2 and 200, and print a message # for each one foreach my $counter (2 .. 200) { print "Whoa, the counter is $counter!\n"; } |
1 2 3 4 5 6 7 | # delete old files, warn if they can't be removed foreach (@myfiles) { unlink $_ or warn "Couldn't remove $_: $!"; } print "whodunit.pl is done!\n"; # tell the user we're done exit; # exit peacefully |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # print_help: help handler, prints out help for whodunit.pl and exits sub print_help { # print the help itself print << EOHIPPUS; This is help for the whodunit.pl program. You can pass options to whodunit.pl as command-line arguments. For example: ..../whodunit.pl -h ..../whodunit.pl -show suspects List of options: -h : print this help -show : show the suspects, victims, or detectives (all of them if no second argument is specified) -quiet : print no information other than the killer's name EOHIPPUS exit; # do nothing else, just exit quietly } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |