in reply to Re: Re: Opening Unknown Filenames
in thread Opening Unknown Filenames

I hardly think using "glob" is more readable, though <$dir/*> might be.

I'm not really sure it is though. It's more compact, to be certain. Assuming what I did in removing the dotfiles is an invariably desired behavior, the glob works fine. But I'd rather use an explict readdir on account of, what if I decide I want the dotfiles after all? If I'm using a readdir I only have to change the grep to grep { ! /^\.\.?$/ } or  grep { /[^\.]/ } whereas if you're using glob, you have to change the whole thing to use the readdir anyways. And so if you always start with glob, as soon as you need a dotfile you'll find yourself with a mixed bag using both. Hardly more readable, that.

If the tools isn't a sysadmin tool, it might be fine to assume you're not wanting to include dotfiles.
--
Snazzy tagline here

Replies are listed 'Best First'.
Re: Re: Re: Re: Opening Unknown Filenames
by diotalevi (Canon) on Jul 06, 2003 at 03:59 UTC

    <$dir/*> is exactly the same as glob "$dir/*", just spelled differently. I spell glob() explicitly so there isn't confusion (in other programmer's minds) about when I mean readline() or glob(). Since the stated code went to efforts to remove ., .. and the dot files it is perfectly valid (and for this purpose) clearer to only code for that.

    If the code needed to handle dot files then it makes sense to use readdir. That just isn't the case here and it adds unnecessary obfuscation.