Loading ...
Sorry, an error occurred while loading the content.
 

double-regexp necessary?

Expand Messages
  • Paul Archer
    I ve got a series of directories whose structure I m trying to parse to build a list of links (via HTML::Mason). I m coming up with a list of directories kind
    Message 1 of 1 , Feb 26, 2004
      I've got a series of directories whose structure I'm trying to parse to
      build a list of links (via HTML::Mason).

      I'm coming up with a list of directories kind of like this:

      images
      images/dir1
      images/dir1/subdirA
      images/dir1/subdirB
      images/dir1/subdirC
      images/dir2
      images/dir2/subdirA
      images/dir2/subdirB
      images/dir2/subdirC
      images/dir2/subdirC/subsubdirX
      images/dir2/subdirC/subsubdirY
      images/dir2/subdirC/subsubdirZ

      and so on, to an arbitrary depth.
      I want to display them something like this:

      images
      |_>dir1 [wouldn't show the subdirectories here, assuming the user is in
      the dir2 structure]
      |_>dir2
      |_>subdirC
      |_>subsubdirX
      |_>subsubdirY
      |_>subsubdirZ


      The question is--well, the first question really is: does anyone know of
      some prebuilt code to do this kind of layout? I'd rather not reinvent the
      wheel.
      But other than that, the question is, what's the easiest way to do the
      transformations on my list? I know I need to leave the base directory name
      alone, replace its parent with an arrow, and replace any path elements above
      that with a tab (or whatever). But is there any way to do that with a single
      substitute operator? Or should I be looking at something like a 'map', or
      even 'split'ting the path and working on individual elements?

      TIA,

      Paul Archer


      ----------------------------------------------------------
      Reporter: "What do you think will be the biggest problem
      in computing in the 90's?"
      Paul Boutin: "There are only 17,000 three-letter acronyms."
      ----------------------------------------------------------
    Your message has been successfully submitted and would be delivered to recipients shortly.