in reply to question regarding slices

Using glob() is the best solution, since it doesn't include . and .. in the solution set. But, in general, if there are things you want to skip over, I find the NEXT statement with conditional modifier is the clearest solution:

foreach ( readdir PRINT ) { next if ( ( $_ eq '.' ) or ( $_ eq '..' ) ); # or, alternately ... next if /^..?$/; }

The first line is explicitly clear and is fast. Regex cannot be faster than straightfoward string comparison, but in this case the small number of characters and the idiomatic nature makes the code clear to undnerstand.

--
TTTATCGGTCGTTATATAGATGTTTGCA

Replies are listed 'Best First'.
Re: Re: question regarding slices
by sgifford (Prior) on Nov 07, 2003 at 16:01 UTC
    Your RE will skip any one- or two-letter entries, not just . and .., since . in an RE means "any character." I think you meant /^\.\.?$/.