in reply to Re^2: Writing to file...
in thread Writing to file...

glob is not that portable (BSD,DOS,Windows,SYS V), it is a mess. I prefer readdir and grep over glob.

In what respect? As long as you are using forward slashes for your pathes (in particular important if you are on Windows and dealing with UNC pathes), the fine thing about glob is that it works the same on all platform, since it doesn't rely on platform specific issues. At least this is true for any "reasonably recent" Perl; I darkly remember that for very early versions of Perl, glob used the shell mechanism on some platforms, which led to compatibility problems ... but this was long time ago.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^4: Writing to file...
by Marshall (Canon) on Jul 22, 2009 at 12:54 UTC
    Ronald, I would beg to differ. Glob can be a real mess. grep and readdir works on all platforms.

    The forward vs backslash is not an issue. Perl'ers take note: always use "/" instead of some convoluted "\\" idea for a Windows path. Perl will translate the "/" into the right thing for Windows.

    Update:
    There are plenty of "old" Perl 5.6 programs out there! I skipped 5.8 and went to 5.10, so I don't know what 5.8 does. The glob mess that exists in 5.6 is gonna be around for a long time.

      Glob can be a real mess.
      Could you give a concrete example? If this is the case, I would conclude that this is a bug to be reported. From doc:://File::Glob:
      File::Glob::bsd_glob() implements the FreeBSD glob(3) routine, which is a superset of the POSIX glob() (described in IEEE Std 1003.2 "POSIX.2"). bsd_glob() takes a mandatory "pattern" argument, and an optional "flags" argument, and returns a list of filenames matching the pattern, with interpretation of the pattern modified by the "flags" variable. Since v5.6.0, Perl's CORE::glob() is implemented in terms of bsd_glob().

      -- 
      Ronald Fischer <ynnor@mm.st>
        This glob() weirdness is at least an ActiveState issue in their version 5.6 series, especially when trying to make .exe files. They have made progress with this in Perl 5.10, but I actually don't know if it is completely fixed or not. The grep on a readdir will always work.

        There is sometimes differences between the "spec" and what the code actually does, especially when dealing with multi-platform issues and in particular Windows vs *nix.