create new tag
, view all tags
$incfile =~ s/(^|\/)\./$1/g;

This came from Codev.TopicsWithPasswdInNameCannotBeIncluded.

Here is how I analyze it:

Oops: I thought, from the discussion in Codev.TopicsWithPasswdInNameCannotBeIncluded that this would look for a filename with a preceding "." (in other words, a hidden file) and delete it. If my understanding of the substitution statement is correct, it does not do that. Either my understanding is incorrect (probably most likely), there is an error in the statement, or I misunderstand the purpose of the statement.

  • First, if I see an "s" in (near the beginning of?) a Perl statement, I look to see if I find three matching characters as the delimiter in a substitution statement, although normally a "/" can be almost anything (IIRC). (Similarly, if I see an m, I look for two matching characters. Do I recall that the "s" and "m" are optional also?) (This is a general approach -- I should rewrite it and put it somewhere like RegexExpRecognizingAPerlRegex.)
  • Now I see a few clues -- the something in parenthesis and the $1 tell me that the something in parenthesis is being saved in a "named variable(?)" ($1) for use later.
  • Idiomatically, the ^|\/ matches an optional "/" at the beginning of a string. (I need to dig into this deeper -- does it also match anything before that like a preceding word (or path, in this case?).)
  • In any case, it saves the "/" (or <path>"/"?) as $1.
  • Next, it looks for and tries to match a "."
  • This is a substitution statement. If it finds a ".", it replaces it with whatever matched in the (^|\/) portion of the regex.
  • Aside: Note that a "." is often used as a pattern to match anything (often used like ".+", ".*", or ". (???)). In the above pattern, the . is "escaped" using the \ which means the pattern matches a "real" period.

Aside: If I were to attempt to rewrite it to delete any file name preceded by a period, I might try this:

  • $incfile =~ s/(^|\/)\.(.+)/$1/g;

This would leave the path but delete the "." and filename. (I'm not sure what value leaving the path has.)

See AboutThesePages.

<Currently, no significant content below this line.>




See ResourceRecommendations. Feel free to add additional resources to these lists, but please follow the guidelines on ResourceRecommendations including ResourceRecommendations#Guidelines_for_Rating_Resources.


  • (rhk) [[][]] --

Recommended for Specific Needs

  • (rhk) [[][]] --

Recommended by Others

  • (rhk) [[][]] --

No Recommendation

  • (rhk) [[][]] --

Not Recommended

  • (rhk) [[][]] --


  • () RandyKramer - 26 Jul 2002
  • <If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.>

[[Main.RandyKramer#26 Jul 2002][]]

Rants (Ignore)

See MyRantings.

Page Ratings

Topic revision: r1 - 2002-07-26 - RandyKramer
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look