Search code examples
perl

Trying to get source code of a webpage in perl


I'm trying to get a html source of a webpage using the Perl "get" function. I have written the code 5 months back and it was working fine, but yesterday I made a small edit, but it failed to work after that, no matter how much I tried. Here is the code I tried.

#!usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
my $link = 'www.google.com';
my $sou = get($link) or die "cannot retrieve code\n";
print $sou;

The code works fine , but its not able to retrieve the source, instead it displays

cannot retrieve code

Solution

  • my $link = 'http://www.google.com';