Any data HTML::LinkExtor accumulates is not cleared between documents.
@links is ever growing.
Unrelated problems:
Using foreach to loop over an ever-growing array is not recommended. ("If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body.") Use a while loop instead.
When using $p->parse, you need to end with $p->eof.
The "skipping" check should be done on absolute uris.
@visited should be a hash to avoid the "skipping" loop.
/$domain/ is not a safe method to accomplish the desired option.