open LOG, "<", "logfile.txt"; $count = 0; while ($line = ) { @words = split(/ /, $line); for($i = 0; $i < @words; $i++) { if ($i eq 0) { @bt = split(/\./, $words[0]); for($b = 0; $b < 4; $b++) { print "the $b IP byte is $bt[$b]\n"; } } print "$words[$i]\n"; } $count = $count + 1; } close LOG; print "\n$count lines read in\n";