in reply to Re^3: Formatting of printed SQL Query output
in thread Formatting of printed SQL Query output

...or, since you ask for with borders (presumably to make it look like directly using your db's output capabilities), print your headers and initial set of borders outside the loop, and modify GrandFather's printf slightly (to provide the column-separating border, as follows:

use strict; use warnings; print " Co.ID \t|\tNAME\n"; print "-------\t|------------------------\n"; my @rows = ( '16444 3M Singapore', '10167 ABB Schweiz (CHHOS) - SAP', '13916 ABB Turbo Systems AG - LVS', '10163 ABB Turbo Systems AG - SAP', '8683 ABC', ); printf "%6d\t|\t%s\n", split ' ', $_, 2 for @rows;

OUTPUT:

 Co.ID  |       NAME
------- |------------------------
 16444  |       3M Singapore
 10167  |       ABB Schweiz (CHHOS) - SAP
 13916  |       ABB Turbo Systems AG - LVS
 10163  |       ABB Turbo Systems AG - SAP
  8683  |       ABC

Minor Note: Since laziness is a virtue, check on the string repetition operator (for example, p25 of "Learning Perl," O'Reilly, Randal L. Schwartz & Tom Phoenix, which should be on your bookshelf) for a way to get the multiple "-"s with fewer keystrokes.