Replace ETH0 with the interface you need..

 

my $IP = `ifconfig eth0| awk ‘/dr:/{gsub(/.*:/,””,\$2);print\$2}’`;

$IP =~ s/\s+$//;