in reply to File::Random module

Anybody knows Why?

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

I wouldn't use this module, look inside, all it does is call File::Find

I would use Path::Iterator::Rule

Replies are listed 'Best First'.
Re^2: File::Random module (bug)
by McA (Priest) on Apr 02, 2013 at 07:41 UTC

    Can you show the bug? I'm a bit surprised as the module runs well in a little test case I made on Windows. The only thing which wonders me is, that File::Find's path seperator seems to be '/' in any case. Have a look at while running under Windows:

    #!/usr/bin/perl use strict; use warnings; use File::Find; find(\&wanted, 'C:\\Temp\\something'); sub wanted { print "$_\n"; print "$File::Find::name\n"; }

    @gautamparimoo: I can adress a drive 'Z:\' here on my installation. Silly question, but are you sure you have a 'E:\'? Show us the whole script and we can probably see where the problem is.

    McA

      @McA

      What i have shown is the only script i am trying coz i have not integtated it still because the code snippet is not working.Also I have seen than when I input C: drive(which is the drive from which the script is being run) it gives the correct output But the returned filenames are not from the whole C: drive just the subdirectory from where I am running the script. So when i input drive as E: than i get the same error as shown above. It is kind of a strange thing. Did u run it and what did u get?

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

      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

        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

        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