Answer the question
In order to leave comments, you need to log in
Parsing ip from 2ip to perl?
Help with a simple example of parsing ip from 2ip.ru to perl
Answer the question
In order to leave comments, you need to log in
Something like
my ($ip) = $page_content =~ m|<span>\s*Ваш IP адрес:\s*</span>.*?<big.*?>((?:\d{1,3}\.){3}\d{1,3})</big>|ism;
#!/usr/bin/env perl
# Включаем варнинги и ужесточение синтаксиса
use strict;
use warnings;
# Включаем библиотеку для работы с http
use LWP::Simple;
# Качаем страницу, если не удалось пркращаем работу
my $page = get('http://2ip.ru/') or die "Can't get page!";
# Парсим IP ргуляркой если не удалось прекращаем работу
my ($ip) = ($page =~ m!(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})!) or die "Can't pars IP!";
# Выводим IP
print 'You IP: '.$ip."\n";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question