http://qs321.pair.com?node_id=380612

Inspired by Regexp to match IP address, I thought of golfing the smallest Perl expression (not necessarily a regular expression) that, when using strict and warnings, evaluates to true if $_ is a valid numeric IPv4 decimal address.

Those addresses can be:

    A single decimal number between 0 and 256 ** 4 - 1
    Two decimal numbers separated by a dot, the first between 0 and 255 and the second between 0 and 256 ** 3 - 1
    Three decimal numbers separated by a dot, the first two between 0 and 255 and the third between 0 and 65535
    The more usual four decimal numbers between 0 and 255 separated by a dot

Here is the first naive attempt to get the ball rolling. It's 24 + 39 + 54 + 64 = 181 characters, easy to beat!

Update: It looks like I didn't make myself clear, when I said "smallest expression" I meant "smallest valid Perl expression", I didn't mean "regular expression"

# 1 2 3 4 5 6 #234567890123456789012345678901234567890123456789012345678901234 (/^(\d+)$/&&$1<256**4)|| (/^(\d+)\.(\d+)$/&&$1<256&&$2<256**3)|| (/^(\d+)\.(\d+)\.(\d+)$/&&$1<256&&$2<256&&$3<256**2)|| (/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/&&$1<256&&$2<256&&$3<256&&$4<256)