Re: creating an index of files contents

[email protected] ("Mathias Kratzer") Fri, 23 Sep 2016 15:17:12 +0200
Newsgroups perl.perl4lib
Message-ID <[email protected]>
Dear Sergio,

I'd traverse the dirs by means of a glob and build the following two =
hashes

%content
with the dirs $dir as keys and a reference to an array or hash of the =
numbers contained in any file of $dir; in case you cannot guarantee that =
any number occurs only once I would opt for the hash as this would allow =
to (1) count the occurances for each number as the hash value and (2) =
retrieve a list of the distinct numbers by calling the keys builtin on the =
hash.=20

%index=20
with the numbers $number as keys and a reference to an array of the dirs =
containing a file that contains $number.

Hope this helps
Mathias


--=20
_____________________________________________________________________
)_______
)_______     Dr. Mathias Kratzer
)_______     Head of Library Network Services
)_______     Bavarian Library Network (BVB) / Head Office
)_______     Bavarian State Library
)_______     Ludwigstra=C3=9Fe 16=20
)_______     D-80539 M=C3=BCnchen
)_______     Phone# +49 89 28638-2797  |  Fax# +49 89 28638-2605
)____________________________________________________________________


>>> On Freitag, 23. September 2016 at 08:48, Sergio Letuche
<[email protected]> wrote:
> hello community,
>=20
> Say we have the following structure in our filesystem:
>=20
> dir1
> dir2
> dir3
> dir4
>=20
> dir stands for directory of course.
>=20
> In dir1, there is a file1.txt that has in it numbers, like below
>=20
> 6576576  898798789  5645436549  76567576576  876876876876
>=20
> Same goes for dir2. In dir2, there is a file2.txt, that has in it =
numbers,
> like below
>=20
> 6576576  89879878963  56454365492  765675765763  8768768768765
>=20
> And so with all the rest of the folders.
> What we need to do, is have a new file (like an index) out of all
> directories and files values, like below:
>=20
> dir1;6576576,898798789,5645436549,76567576576,876876876876
> dir2;6576576,89879878963,56454365492,765675765763,8768768768765
>=20
> And secondly, another index file, which will have the reverse info
>=20
> 6576576;dir1,dir2
>=20
> Any ideas on how would you approach this?
>=20
> Best