Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Perl IP's etc


On Mon, Sep 17, 2001 at 09:25:07AM +1000, Crossfire wrote:
> my @splitline = split /\s+/, $line;
> my @ipaddr = ();
> foreach $i (@splitline) {
> 	if ($i =~ m/^\d+\.\d+\.\d+\.\d+$/) {
> 		push @ipaddr, $i;
> 	}
> }

> 	if ($i =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) ...

  Yuck :)

  my @ips = grep { /^(\d{1,3}\.){3}\d{1,3}$/ } split /\s+/, $line;

m.