in reply to print join n times on a line

local $, = ", "; local $\ = "\n"; while (@GetServiceList >= 7) { print splice @GetServiceList, 0, 7; } print @GetServiceList if @GetServiceList;

Replies are listed 'Best First'.
Re^2: print join n times on a line
by ambrus (Abbot) on Apr 13, 2011 at 08:19 UTC

    Correct, but let me note that there's no need for two print statements: this can be simplified to just the following.

    local $, = ", "; local $\ = "\n"; while (@GetServiceList) { print splice @GetServiceList, 0, 7; }
      Yeah, but then you have to remember when you can be out of bounds with splice/substr, and when it gives a warning or an error. I can never remember ;-)