Feb 27, 2000, 6:41 AM
Post #11 of 11
Well, if we're going to play Perl Golf with "how do I get the first three sections of an IP address?", then I offer these two:
Re: (How) Can I shorten a logged IP?
[In reply to]
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>
$short = substr $IP, 0, rindex($IP, ".");
($short = $IP) =~ s/\.[^.]+$//;
In tests, the substr+rindex method is faster.