After extracting, I want to put each IP Address I extracted & printed on the screen into an array. How can I do this? Here is my code:
#!/usr/bin/perl
use HTTP::Request;
use LWP::UserAgent;
my $url = 'http://www.game-monitor.com/';
my $request = HTTP::Request->new(GET => $url);
my $useragent = LWP::UserAgent->new();
my $response = $useragent->request($request);
my $result = $response->content;
开发者_运维知识库
@m = ($result =~ /\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b/sg);
foreach (@m) {
print "$_\n";
}
}
What do you mean? Your IPs already are in an array, @m
, but if you want to put them in something else, one at a time, you can use push @somethingelse, $_
Also, you should always use strict; Add these lines to top of your code:
use strict;
use warnings;
精彩评论