in reply to Re: glob: where are the full paths?
in thread glob: where are the full paths?

Hi,

Thanks for the response.

glob expands * but you have to give it full paths

Ok.

Be careful to use forward slashes.

Yep.

For full caveats see 'perldoc -f glob' and File::Glob

I read both before I posted. They weren't helpful. There doesn't seem to be anything in the docs that discusses the return value of glob. The only thing of note (to me) in the File::Glob docs was this:

The C glob code has the following copyright: Copyright (c) 1989, 1993 The Regents of the University of Californ +ia. All rights reserved. This code is derived from software contributed to Berkeley by Guido van Rossum.
.

Monks, bow down and hail the BDFL. The True Path has been revealed.

Replies are listed 'Best First'.
Re^3: glob: where are the full paths?
by Khen1950fx (Canon) on Nov 14, 2009 at 06:41 UTC
    Another way to do it:

    #!/sw/bin/perl use strict; use warnings; use File::Glob ':glob'; my @files = </sw/bin/*>; foreach my $file (@files) { print $file . "\n"; }

    I'm using Tiger. Here, it shows me all the files in /sw/bin.

      Hi,

      My book mentions legacy code may contain that syntax--even though it it used to be inefficient because it caused a separate process to start up. I find that I don't have to import ':glob' (or anything else from File::Glob) for that syntax to work.

      Thanks.

        I've written code in various flavors that use 3 different types of "glob". My experience with this is that: "friends don't tell other friends to glob"! I am quite sure that your program with the default glob works in your test cases, on your Operating System. You presented the most simple case of "give me all files in the directory that my program is running in". Some Monks figure that POSIX glob is the way to go. I've run into platform and Perl version problems with that. I figure that no glob is the way to go.

        because it caused a separate process to start up.No. A Perl "use" statement doesn't cause that to happen.

Re^3: glob: where are the full paths?
by Anonymous Monk on Nov 14, 2009 at 07:23 UTC
    Um, this is not slashdot.