1: #!/usr/bin/perl -w 2: # rtfm - read the friendly manual/s 3: # 4: # Usage: rtfm [number of man pages to read] 5: # 6: # Originally written by Daniel N. Andersen, June 2004 7: # Modified by just about everyone at perlmonks.org 8: 9: use strict; 10: 11: my $lines = 0; 12: my $loop = 1; 13: my $select; 14: 15: if($ARGV[0]) 16: { 17: $loop = $ARGV[0] unless($ARGV[0] =~ /\D/); 18: } 19: 20: while($loop) 21: { 22: foreach my $path (split(/:/, $ENV{'PATH'})) 23: { 24: opendir(PATH, $path); 25: while(defined($_ = readdir(PATH))) 26: { 27: if(-f "$path/$_") 28: { 29: $lines++; 30: $select = $_ if int(rand($lines)) == 0; 31: } 32: } 33: closedir(PATH); 34: } 35: system(man => $select); 36: $lines = 0; 37: $loop--; 38: }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: rtfm
by grinder (Bishop) on Jun 22, 2004 at 09:42 UTC | |
Re: rtfm
by Roy Johnson (Monsignor) on Jun 22, 2004 at 16:21 UTC | |
by dna (Beadle) on Jun 22, 2004 at 18:43 UTC | |
Re: rtfm
by Ven'Tatsu (Deacon) on Jun 22, 2004 at 13:27 UTC | |
Re: rtfm
by dna (Beadle) on Jun 22, 2004 at 13:39 UTC |
Back to
Craft