in reply to File::Find problems

Sheesh. The problem is here:

my $volume_name = "/Volumes/Volume Name/"; for (glob "$volume_name/*")

That ends up globbing for "/Volumes/Volume Name//*". I'm not sure how that successfully returns the files I am after, but that is screwing up the path in File::Find. Is there a function that joins pieces of paths, so as not to create that double slash?

Replies are listed 'Best First'.
Re^2: File::Find problems
by FalseVinylShrub (Chaplain) on Jan 15, 2010 at 07:37 UTC

    Hi

    Yes. You can avoid embedding the path separator by using File::Spec. Though for throwaway scripts I don't normally bother.

    I find the Functions version more convenient when not doing anything complicated with it:

    use strict; use warnings; use 5.010; use File::Spec::Functions qw(catfile rootdir); my $volume_name = catfile(rootdir, 'Volumes', 'Volume name'); say catfile($volume_name, '*');

    Hope this helps.

    FalseVinylShrub

    Disclaimer: Please review and test code, and use at your own risk... If I answer a question, I would like to hear if and how you solved your problem.

Re^2: File::Find problems
by ikegami (Patriarch) on Jan 15, 2010 at 07:58 UTC
    "/" is a directory separator. Why do you have a trailing slash? It's not separating anything. Various modules will canonize paths, removing "./" and doubled separators from paths and trailing slashes, but that's just a cosmetic thing. The doubled slash will work perfectly fine.