Tree View

Discussion in 'Perl Misc' started by Sandeep, Jul 4, 2005.

  1. Sandeep

    Sandeep Guest

    hi list,

    this is the first time i am posting in the list. i am working to create
    a utility that rsyncs the desired folder of the volume to a sepecified
    destination. i can get the list of all the folders in a particular
    volume. the format i am getting is below
    -------Format Begin-----
    ..
    demo
    demo/bulkmail
    demo/images
    demo/images/bulkmail
    demo/productivity
    demo/webpresence
    errors
    htmlasp
    images
    images/defaultlogo
    info
    info/htmlasp
    info/images
    info/mew
    newsletter
    newsletter/newyear05
    newsletter/november04
    newsletter/october04
    newsletter/september04
    others
    photos
    public_html
    public_html/menu
    -------Format End-----
    and the tree structure is
    ..
    |
    +---demo
    | |
    | +--bulkmail
    | |
    | +--images
    | | |
    | | +--bulkmail
    | |
    | |
    | +--productivity
    |
    +---errors
    |
    |
    +---htmlasp
    |
    |
    +---images
    | |
    | +--defaultlogo
    |
    +---info
    | |
    | +--htmlasp
    | |
    | +--images
    | |
    | +--mew
    |
    +---newsletter
    | |
    | +--september04
    | |
    | +--october04
    | |
    | +--november04
    | |
    | +--newyear05
    |
    +---others
    |
    |
    +---photos
    |
    |
    +---public_html
    |
    +---menu


    what is the best way to get the tree structure ?? is there any module
    available on CPAN that provides this functionallity.

    Thanks

    Sandeep
     
    Sandeep, Jul 4, 2005
    #1
    1. Advertising

  2. Sandeep wrote:
    >
    > this is the first time i am posting in the list. i am working to create
    > a utility that rsyncs the desired folder of the volume to a sepecified
    > destination. i can get the list of all the folders in a particular
    > volume. the format i am getting is below
    > -------Format Begin-----
    > .
    > demo
    > demo/bulkmail
    > demo/images
    > demo/images/bulkmail
    > demo/productivity
    > demo/webpresence
    > errors
    > htmlasp
    > images
    > images/defaultlogo
    > info
    > info/htmlasp
    > info/images
    > info/mew
    > newsletter
    > newsletter/newyear05
    > newsletter/november04
    > newsletter/october04
    > newsletter/september04
    > others
    > photos
    > public_html
    > public_html/menu
    > -------Format End-----
    > and the tree structure is
    > .
    > |
    > +---demo
    > | |
    > | +--bulkmail
    > | |
    > | +--images
    > | | |
    > | | +--bulkmail
    > | |
    > | |
    > | +--productivity
    > |
    > +---errors
    > |
    > |
    > +---htmlasp
    > |
    > |
    > +---images
    > | |
    > | +--defaultlogo
    > |
    > +---info
    > | |
    > | +--htmlasp
    > | |
    > | +--images
    > | |
    > | +--mew
    > |
    > +---newsletter
    > | |
    > | +--september04
    > | |
    > | +--october04
    > | |
    > | +--november04
    > | |
    > | +--newyear05
    > |
    > +---others
    > |
    > |
    > +---photos
    > |
    > |
    > +---public_html
    > |
    > +---menu
    >
    >
    > what is the best way to get the tree structure ?? is there any module
    > available on CPAN that provides this functionallity.


    This is close to what say you want:

    $ echo ".
    demo
    demo/bulkmail
    demo/images
    demo/images/bulkmail
    demo/productivity
    demo/webpresence
    errors
    htmlasp
    images
    images/defaultlogo
    info
    info/htmlasp
    info/images
    info/mew
    newsletter
    newsletter/newyear05
    newsletter/november04
    newsletter/october04
    newsletter/september04
    others
    photos
    public_html
    public_html/menu" | \
    perl -F/ -ane'print 1..1?$_:"| "x@F.$/."| "x$#F."+--$F[-1]"'
    ..
    |
    +--demo
    | |
    | +--bulkmail
    | |
    | +--images
    | | |
    | | +--bulkmail
    | |
    | +--productivity
    | |
    | +--webpresence
    |
    +--errors
    |
    +--htmlasp
    |
    +--images
    | |
    | +--defaultlogo
    |
    +--info
    | |
    | +--htmlasp
    | |
    | +--images
    | |
    | +--mew
    |
    +--newsletter
    | |
    | +--newyear05
    | |
    | +--november04
    | |
    | +--october04
    | |
    | +--september04
    |
    +--others
    |
    +--photos
    |
    +--public_html
    | |
    | +--menu


    HTH

    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Jul 4, 2005
    #2
    1. Advertising

  3. Sandeep

    Sandeep Guest

    thanks john, that was indeed helpful, thanks a lot. can you suggest
    some book that gives a deep insight of perl regular expressions

    thanks again

    Sandeep
     
    Sandeep, Jul 4, 2005
    #3
  4. On 2005-07-04, Sandeep <> wrote:
    > thanks john, that was indeed helpful, thanks a lot. can you suggest
    > some book that gives a deep insight of perl regular expressions


    If you really want deep insight into regular expressions, you want
    Jeffrey Friedle's "Mastering Reguar Expressions", now in its second
    edition from O'Reilly (http://www.oreilly.com/catalog/regex2/).

    It's not exclusively perl, but it is probably the most detailed book on
    regular expressions you'll ever see.

    dha

    --
    David H. Adler - <> - http://www.panix.com/~dha/
    "Do not look at the cursor! Look where the cursor points!"
    - Chip Salzenberg
     
    David H. Adler, Jul 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ramkumar Menon

    B+ Tree versus Ternary Search Tree

    Ramkumar Menon, Aug 16, 2005, in forum: Java
    Replies:
    2
    Views:
    1,646
    Roedy Green
    Aug 16, 2005
  2. Ramkumar Menon

    B+ Tree versus Ternary Search Tree

    Ramkumar Menon, Aug 16, 2005, in forum: Java
    Replies:
    0
    Views:
    474
    Ramkumar Menon
    Aug 16, 2005
  3. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,234
  4. raki
    Replies:
    1
    Views:
    1,195
    Alexey Smirnov
    Jun 24, 2009
  5. Parthiv Joshi
    Replies:
    1
    Views:
    802
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page