Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: rtfm

by Roy Johnson (Monsignor)
on Jun 22, 2004 at 16:21 UTC ( #368779=note: print w/ replies, xml ) Need Help??


in reply to rtfm

You could also reduce memory overhead (at the expense of more calls to rand) by doing your random keep/toss within the loop:

my $lines = 0; my $selection; foreach my $path (split /:/, $ENV{'PATH'}) { opendir(PATH, $path); while (defined($_ = readdir(PATH))) { if (-f "$path/$_") { ++$lines; $selection = $_ if int(rand($lines)) == 0; } } closedir(PATH) } exec(man => $selection);

We're not really tightening our belts, it just feels that way because we're getting fatter.


Comment on Re: rtfm
Select or Download Code
Replies are listed 'Best First'.
Re^2: rtfm
by dna (Beadle) on Jun 22, 2004 at 18:43 UTC
    Done. The code seems less logical to me now, but what do I know? All we need now is some sort of GUI... :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://368779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (16)
As of 2015-07-30 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls