
japhy
Enthusiast
Feb 27, 2000, 6:41 AM
Post #11 of 11
(1274 views)
|
|
Re: (How) Can I shorten a logged IP?
[In reply to]
|
Can't Post
|
|
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: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $short = substr $IP, 0, rindex($IP, "."); # or ($short = $IP) =~ s/\.[^.]+$//; </pre><HR></BLOCKQUOTE> In tests, the substr+rindex method is faster.
|