I am trying to write a script in perl and trying to extract web links using regular expression from a file called file.txt(which has list of website). I am not able to print the links. Here is my code, thanks :
#!/usr/bin/perl
use strict;
use warnings;
my @web;
open my $input, '<', 'file.txt' or die $!;
#loop through file
while(my $row = <$input>){
chomp $row;
if($row =~ /http:(.+)/) {
push @web, $1;
}
}
for my $w (@web){
print "< $w\n";
}
http: (.+)
will matchhttp:
and then a literal space. How many of your links have a literal space like that?