in reply to Re^2: code explanation
in thread code explanation

i read from help docs which says that the opendir is used to open up a specified directory and the next is like a continue statement in C and i did not understand the part
if /^\.{1,2}$/;

Replies are listed 'Best First'.
Re^4: code explanation
by Anonymous Monk on May 21, 2009 at 14:21 UTC
    the match operator is documented in perlop, and regular expressions are documented in perlre, perlretut... Read perlintro
    use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/^\.{1,2}$/)->explain; __END__ The regular expression: (?-imsx:^\.{1,2}$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- \.{1,2} '.' (between 1 and 2 times (matching the most amount possible)) ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
Re^4: code explanation
by jorgegv (Novice) on May 21, 2009 at 15:51 UTC

    That is a basic regular expression. The instruction basically skips to the next iteration if the name of the element read matches the expression.

    This expression is:

    • ^: Beginning of line...
    • \.: a literal '.'...
    • {1,2}: ...repeated once or twice
    • $ end of line

    It skips the iteration if it finds files or directories with the name "." or "..".