Re: How to use list effectively?
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: 28 Dec 2006 17:55:04 -0800
Gerald W. Lester wrote:
Why Tea wrote:
I have obtained a filelist with "find" in a clearcase vobs. There are
close to 10,000 files. I'm thinking of reading them into a list, then
for any given filename I can quickly search the list to obtain the full
path and spawn an external viewer. I'm sure there are other better and
more efficient ways of doing it. I'd appreciate any suggestion and
better still, with some sample code. Thanks.
It may be better to use an array with the file name as the key and the full
path as the value (or list of values if you want to allow a file with the
same name to exist in multiple directories).
Another option would be to use the full path (including the file name) as
the key with a "1" as the value.
Either way, [array names fileArray $searchPattern] will give you the list
you are looking for.
A big advantage of doing it this way is that [array name] and [array
get] does wildcard by default. So you can for example do searches like:
foreach {fname fpaths} [array get fileArray *.log] { ...
.
- References:
- How to use list effectively?
- From: Why Tea
- Re: How to use list effectively?
- From: Gerald W. Lester
- How to use list effectively?
- Prev by Date: Re: Improving i18n support (Was: Re: Christmas
- Next by Date: Re: Improving i18n support (Was: Re: Christmas
- Previous by thread: Re: How to use list effectively?
- Next by thread: Problem with Threads and starpack
- Index(es):
Relevant Pages
|