$ip = "172.16.100.200"; @octets = ( $ip =~ m/^(\d*)[.](\d*)[.](\d*)[.](\d*)$/ ); foreach $octet (@octets) { printf "%d\n",$octet; }