I would use
my $first = ( split /,\s*/, $line, 2 )[0]
to extract the first element.
I would do the test if $first is an ip address afterwards.
perldoc -f splitIn reply to Re: Regex to take an ip address before a comma
by linuxer
in thread Regex to take an ip address before a comma
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |