in reply to calculate distance between atoms and a target atom

Hi there, it doesn't appear that you have formally declared the $pdbline variable. maybe trying
my $pdbline = <IN>;
would work? But basically, you need declare the new variables with 'my'
or better yet, use a 3 pointed opening method like this:
my $filename = $ARGV[0]; open(my $fh, '<:encoding(UTF-8)', $filename)); while (my $pdbline = <$fh>) {