I have a question that I'm having trouble researching, as I don't know how to ask it correctly on a search engine. 

I have a list of URLs. I would like to have some automated way (Perl for preference) to go through the list and remove all URLs that are top directory only. 

So for example I might have this list: 

<http://www.example.com/hello.html>  

<http://www.foo.com/this/thingrighthere.html>   

In this case I would want to remove example.com from my list, as it is either top-directory only or they reference files in a top directory. 

I'm trying to figure out how to do that. My first thought was, count forward slashes and if there's more than two, eliminate the URL from the list. But then you have trailing forward slashes, so that wouldn't work. 

Any ideas or thoughts would be much appreciated.