The four-line version _was_ needlessly verbose. But
I don't think getting it down to one line is necessary.
Two lines may be about right for this example.
Good code is terse enough that it doesn't take forever
to say anything, but not so terse that it makes the
reader shake his head and drag out reference books.
Somewhere in between ten-thousand-line epics and
golfed-down one-liners there's a happy medium.
Of course, you may not need the @ipaddr array at
all; if you're only using the resulting numbers
once, you may be able to feed the results of the
second line directly into the next function. I'd
have to see the larger context of your code to see
how to further simplify it. But I don't think that
combining your existing two lines into one will make
for greater simplicity.
If you really want to learn serious code *shortening*
techniques, do a Google search for "Perl golf". But
be advised that shorter code isn't always easier to
read. Up to a point it is, but Perl golf has a strong
tendency to go beyond that point. If you just want to
scare your coworker, show him some of the stuff from
the obfuscation section of Perlmonks, and tell him
you're studying programming techniques from the
people who wrote them.
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
|