[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Hoaky MacPerl Regular Expression Question



At 10:16 AM -0700 5/13/99, Chilton Webb wrote:
>I've been knocking this one around in my miniature brain for about a
>month now, so I guess I'm not going to figure it out on my own.
>
>I have a list of files, with this structure:
>
>------
>Macintosh HD:myFiles:a.txt
>Macintosh HD:myFiles:b.txt
>Macintosh HD:myFiles:more:a.txt
>Macintosh HD:myFiles:more:b.txt
>Macintosh HD:myFiles:more:yetmore:a.txt
>Macintosh HD:myFiles:more:yetmore:b.txt
>Macintosh HD:yurFiles:a.txt
>Macintosh HD:yurFiles:b.txt
>------
>
>And I want them in this format:
>
>------
>Macintosh HD
>
>  myFiles
>    a.txt
>    b.txt
>
>    more
>      a.txt
>      b.txt
>
>      yetmore
>        a.txt
>        b.txt
>
>  yurFiles
>    a.txt
>    b.txt
>
>------
>
>Any suggestions?

Don't use regexps.
Split on :, step through the list, keeping track of how "deep" you are
(say, that's easy with split - the number of items returned is the depth
level), add that many whitespaces when you print.

You probably want to keep track of directories and directory changes with a
hash...

Or, maybe one of the File:: modules does this kind of thing already?

-Jeff Lowrey



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org