http://www.perlmonks.org?node_id=83951


in reply to Closest-value-in-list Golf!

First of all I don't think that strict is a very useful restriction in golf. For instance a useful trick is to use punctuation variables like $, because Perl parses $,for differently than $_for. But using $, is strict-compliant in letter even though it definitely is not in spirit!

That said the natural approach at 46 letters happens to be strict-compliant:

sub g{ (sort{abs($a-$_[1])<=>abs$b-$_[1]}@{$_[0]})[0] }