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 usepush @somethingelse, $_Also, you should always use strict; Add these lines to top of your code: