Connected to 192.168.1.13
#!/usr/local/bin/perl
foreach $line(@lines){
if ($line =~ /connected to (.*?)/i) {
$ip=$1;
}
}
but if there are many IP addresses you will want to push() the matches into an array that you can access after the "foreach" loop ends, or process them one by one as you loop through @lines, otherwise $ip will be the last match found in the array.