in reply to using content-type for judgement

Properly indenting your code reveals the problem:

foreach(@urls) { my $ua = LWP::UserAgent->new(); my $url = "$_"; my $response = $ua->head($url); #HTTP::Response type return my $headers = $response->headers(); # HTTP::Headers type retu +rn my $content_type =$headers->content_type(); # string print "$content_type\n"; } if($content_type eq 'application/pdf') { print "File Exists:\n $_"; } elsif($content_type eq 'text/html') { print "File Exists but requires subscription to access:\n"; } else{ print "No Matching found"; }

Your if is outside the loop, so the variable $content_type has gone out of scope, it's value is now undef.

Please use strict; use warnings;, that's a safeguard that catches such errors for you.

And indent your code properly, one indention level per opening curly brace. See perlstyle. As this example illustrates, it's not only a stylistic thing - it is essential for understanding the code.

Also please start by learning the basics of Perl. perlintro and the book "Learning Perl" are good places to start.