#!/usr/bin/perl # use strict; use warnings; # open file for reading open ( XML, "/path/to/file" ) || die "Can't open file $!" while ( ) { # go through line by line $_ =~ ( /(.+?)<\/IP.+?/ ) my $ip = $2; # IP is the value in 2nd parenthesis }