my $type = $response->headers->header("Content-Type"); if (defined $type and $type =~ /^text/) { # ... it's probably text } else { # ... probably not text }