in reply to Passing variable to an email message.

Are you really sure that:
print "$dat\n"; #Print to screen here and it does work here.
...actually prints anything? There's a non-negative probability that you just see the output of:
print $data->{'_headers'}->{'last-modified'};
...and conclude that $dat gets some value while it doesn't!

Update:
You'd better treat what the head() function returns as a list, and take its third element to get what you need (and you need 'last-modified' header, AFAIU). Look:

my $dat = (head('http://web/web.html'))[2]; print "last-modified header value: $dat\n";