in reply to Re^2: A conversation with a C programmer
in thread A conversation with a C programmer

I think
next if $file =~ /^\.\.?$/;
or even
next if $file =~ /^\.+$/; # no longer recommended. see below
is much nicer than
next if $file =~ /^\.{1,2}$/;

But that's just me.

UPDATE/note: yes, the second one will also match files named with any quantity of dots as long as that's the entire filename. In practice, I've never seen a file that started with "..", but I agree it's an issue.

Replies are listed 'Best First'.
Re^4: A conversation with a C programmer
by fizbin (Chaplain) on Mar 25, 2006 at 06:28 UTC
    yes, the second one will also match files named with any quantity of dots as long as that's the entire filename. In practice, I've never seen a file that started with "..", but I agree it's an issue.

    I have, but only on a machine that's been broken into. It is, or at least used to be, common to hide malicious software inside directories called ... -- of course, these days all the l33t kiddies are using loadable kernel modules to hide their directory trees anyway, so it may not be as relevant.

    --
    @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/
Re^4: A conversation with a C programmer
by Anonymous Monk on Mar 16, 2006 at 02:03 UTC

    But that's just me.

    *nod*, I don't at all like your second preference.