0

I need to be able to count the output of the program i have below, the output basically supposed to look like

website-name.com - Breaking news, opinion, politics, entertainment, sports and culture.
Length 89008
Lines 1517

I have tried to create it but, it dosent seem to be working, so a little help would be greatly appreciated

Just for a little background info, the program i am scripting is using LWP::UserAgent; to get content from websites and display it, so what i want to do is to count the output and get the amount of characters.

#!/usr/bin/perl

use strict;
use warnings;
require LWP::UserAgent;



 my $size = length(content);

 my $ua = LWP::UserAgent->new;
 $ua->timeout(10);
 $ua->env_proxy;

 my $response = $ua->get('http://kmra.org/');

 if ($response->is_success) {
     print $response-> title();
     print "$size\n";

 }
 else {
     die $response->status_line;
 }
user218001
  • 35
  • 1
  • 8

1 Answers1

1

You need to get the content after you get the response:

#!/usr/bin/perl

use strict;
use warnings;
require LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->get('http://kmra.org/');

if ($response->is_success) {
  my $size = length($response->content());
  print $response->title();
  print "$size\n";
} else {
  die $response->status_line;
}
imran
  • 1,560
  • 10
  • 8