in reply to Newline in left-justified string for %s warning

As indicated by Skeeve, the problem hinges on how you are assigning values to your @rel array. In your latter example, where you just assign a set of quoted strings -- and none of those strings contain a newline ("\n") -- you don't get the warning, because the values you pass to sprintf to fill the "%-8s" left-justified field do not contain newlines. (And if you provide two values for the two "%s" slots, you won't get any warnings.)

Meanwhile, if you were originally assigning values to @rel via input from STDIN or another file handle, then it would appear that the strings all have a "\n" at the end (or a literal "\r\n", depending on your OS).

If you "chomp" @rel before passing the values to sprintf, there will be no warnings about newlines -- and the output will appear as specified in the format string, without a newline showing up in front of the " (x".

For that matter, it would be best to do  chomp @rel before you use those values as hash keys in %rel_hosts. Having newlines at the ends of hash key values strings is quite unnecessary and generally undesirable.