in reply to Re^2: File::Random module (bug)
in thread File::Random module

Can you show the bug?

Yes I can, but I'm not interested, the OP already showed the bug

Pay attention to the module name McA

Replies are listed 'Best First'.
Re^4: File::Random module (McA)
by McA (Priest) on Apr 02, 2013 at 09:01 UTC

    Hi Anonymous Monk,

    you write

    Yes I can, but I'm not interested...
    That'a pity. I couldn't see where File::Random (I'm aware of the module name) does some path mangling without being careful to '/' or '\' so it produces the above error while using File::Find (I'm aware of the module name).

    The OP gave the error message

    OUTPUT:Can't stat E:: No such file or directory at C:/Perl/site/lib/File/Random.pm line 121
    looking at line File::Random line 121 shows that this is a call to find from File::Find (IAOTMN) at least in version 0.17 of File::Random.

    To clarify and sum it up for the interested readers:

    • I made a litte test script with File::Random which worked pretty well under Windows even addressing a drive letter, e.g. Z:\
    • Looking at File::Random line 121 (version 0.17) showed that there is a call to File::Find::find. As I've seen that File::Random also uses $File::Find::name I made a little test script to see how File::Find behaves under Windows which I don't know.
    • As I said above and showed with a little test script I was wondering to see the output of the path names produced by File::Find having '/' in it. But anyway both test scripts work even if addressing a path with a drive letter.
    • I concluded without deeper analysis that the way how File::Random was called produces the error or shows the reason for the bug. Therefor I asked the OP for more information.

    Hopefully someone else shares his Monks's wisdom and shows us the seemingly obvious bug in File::Random.

    McA

      ... That'a pity ... seemingly obvious bug in File::Random.

      Its not as if I described it, its not as if I said the Bug in File::Random, it does't use File::Spec or another file path module, it rolls its own code, and naturally its linux-centric

       E:/ is a different directory from  E: and  E:: isn't a directory at all

Re^4: File::Random module (McA)
by gautamparimoo (Beadle) on Apr 02, 2013 at 08:54 UTC

    I saw the module Path::Iterator::Rule. But how am I gonna implement randomness through this module?

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

      Fairly easily...

      use PIR; my @files = PIR->new->file->all($some_dir); printf "Random file is: %s\n", $files[rand @files];
      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

        Thank you for the snippet (++). Could you prove on Windows?

        McA

      Hi,

      I just wanted to spend some more time to help you with this question, but as I tried to install Path::Iterator::Rule (I'm aware of the module name) on Windows (Strawberry Perl) I got errors from tests. You guess it: Concerning path/drive letter seperator.

      Sorry, I can't help you at the moment even being interested.

      UPDATE: David made an update of the package. Look at Re^5: File::Random module (Path::Iterator::Rule).

      McA