use feature 'say'; # a better "print" use Mojo; ###################################################### my $insert_str = "https://www.somesite.com"; #get the pages to fetch from the links.txt file open (LINK, "links.txt") || die "couldn't open the file!"; my $ua = Mojo::UserAgent->new; #loop through all of the urls while ($record = ) { say ("Getting web site info for: $record\n"); #determine the new file name by the subdirectory / path since all fetched pages will be index.html $newFileName = (substr $record, (rindex($record, "/", (rindex($record, "/") -1)) + 1), (rindex($record, "/") - rindex($record, "/", (rindex($record, "/") -1)) -1)) . '.html'; print("Should save the information to a new file as $newFileName\n"); #get the page contents my $response = $ua->get($record)->res->dom; if ($response->is_success) { #Find the