in reply to @addrs = (gethostbyname('www.yahoo.com'))[4..-1] ?

Write a nice, three-line sub that performs the desired operation and returns what you want.

This subroutine is now responsible for doing what you want, regardless of its current implementation.   The subroutine now clearly “does what you mean,” and anyone who looks at the code will see a subroutine-call to a meaningfully-named routine.

“Always write code to say what, not how.”