sub get_object
{
my($agent, $url, $referer, $save_path); # args: LWP::UserAgent, url to get, (op
+tional) referer to grab that url with, (optional) path to save it to
my($request, $response, $content); # http stuff
$agent = shift();
$url = shift();
$referer = shift();
$save_path = shift();
####
my($agent, $url, $referer, $save_path) = @_;
# args:
# $agent - LWP::UserAgent object
# $url - URL to get
# $referer - referer to grab URL with (optional)
# $save_path - path to save image/etc. to (optional)
my($request, $response, $content); # for http stuff
####
# ...
$save_path ? print("Getting picture $url...") : print("Getting info from $url\n");
####
print $save_path ? "Getting picture $url..." : "Getting info from $url\n";
####
print defined $save_path ? "Getting picture $url..." : "Getting info from $url\n";
####
my $type = $response->headers->header("Content-Type");
if (defined $type and $type =~ /^text/) {
# ... it's probably text
} else {
# ... probably not text
}