in reply to glob: where are the full paths?

glob expands * but you have to give it full paths
$ pwd C:\strawberry\c $ perl -le"print for glob shift" * bin contrib COPYING COPYING.LIB doc include lib libexec mingw32 share $ perl -le"print for glob shift" C:/strawberry/c/* C:/strawberry/c/bin C:/strawberry/c/contrib C:/strawberry/c/COPYING C:/strawberry/c/COPYING.LIB C:/strawberry/c/doc C:/strawberry/c/include C:/strawberry/c/lib C:/strawberry/c/libexec C:/strawberry/c/mingw32 C:/strawberry/c/share $ perl -le"print for glob shift" C:/strawberry/c/*/info/* C:/strawberry/c/share/info/dir C:/strawberry/c/share/info/make.info C:/strawberry/c/share/info/make.info-1 C:/strawberry/c/share/info/make.info-2 $
Be careful to use forward slashes. For full caveats see 'perldoc -f glob' and File::Glob.

Replies are listed 'Best First'.
Re^2: glob: where are the full paths?
by 7stud (Deacon) on Nov 14, 2009 at 06:16 UTC

    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.

      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.

      Um, this is not slashdot.