Chris wrote:
Hi Guys,

        I have something im basically stumped on, so mabey somebody can
give me a hand ;)

This is my scenario:

I have a bunch of random URL's in a plain text file. I also have a text
file with just the domain of certain URL's that are in the random URL
file.

IE: random file:
something.google.com
whoknows.yahoo.com
another.thisisp.com
perl.code.com

IE: other file:
yahoo.com
google.com

And so on..

What I need to do is the following:

Suck the random file into an array, then look through the other text file
line by line, and sort out any matching domain in the random URL file that
matches a domain in the file with just the domains, and make an array of
random urls that would be grouped by each particular domain listed in the
domain only file. The remaining URL's in the random file would be put into
another array by them selves. I have started some code, but since im kinda
new to perl, i really don't even know if it makes sense.. some of it works
some of it doesn't..


Let's have a look at your data structure. Assuming your list is not to long and you have enough memory then you should consider using a hash of arrays. First you could read in your list of domains setting each unique domain to a hash key that stores an array reference as its value. Then you step through the urls stripping out their domain, if the hash key exists then you push the url to that array, otherwise you push it to some miscellaneous array. The other option would be to scrap the second list of domains all together and push each unique domain from the list of URLs to a hash key, then you are guaranteed a list of unique domains, and the urls at each domain, but this changes your business logic a little which is why I offer it as a second method. I am assuming as a beginner you haven't dealt with references much, you may want to have a look at:


perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc

Lots of reading and don't hope to get it all on teh first pass, but it will be invaluable if you can start using references.

http://danconia.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to