in reply to multiple matches per line *AND* multiple capture groups per match

Special_K:

The URL part is always constant, so instead *just* capture the filenames, then build the URLs:

if (@filename = ($_ =~ /$test_regexp/g)) { my @complete_urls = map { "http://...." . $_ } @filename; ... }

Alternatively, capture the URL and split off the filenames:

if (@complete_urls = ($_ =~ /$test_regexp/g)) { my @filename = map { s{^.*/}{}; $_ } @complete_urls; ... }

...roboticus

When your only tool is a hammer, all problems look like your thumb.