in reply to Re: code explanation
in thread code explanation

Virtually every reply to your first question showed you how to try to answer basic questions yourself... maybe you should give that a try, then let everyone know what parts you didn't understand.

Replies are listed 'Best First'.
Re^3: code explanation
by Anonymous Monk on May 21, 2009 at 14:17 UTC
    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}$/;
      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 ----------------------------------------------------------------------

      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 "..".