in reply to Re^6: File::Random module (McA)
in thread File::Random module

@tobyink That was not what i meant by random.. This think can be easily done the same way as u did by find(). Through random I wanted to see the random file as it is ie dont wanna create a array first and then select random files from it. Rather traverse the drive such that i get random files to process while traversing.. Any ideas?

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. -Elbert Hubbard

Replies are listed 'Best First'.
Re^8: File::Random module (McA)
by tobyink (Canon) on Apr 02, 2013 at 16:17 UTC

    The following crawls a directory and prints out random file names. Each file has a 1 in 10 chance of being selected.

    use PIR; my $iter = PIR->new->file->iter($somedir); while (defined(my $file = $iter->())) { next if int rand 10; print $file, "\n"; }
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name