in reply to Formatting of printed SQL Query output

There are lots of ways of doing this in perl. I'd probably use sprintf to format a string and then print it out, but you could also just try using tab characters (put a literal \t in your output string).

You could even use the old and much-maligned perl formats perlform, but lots of people feel that they have outlived their usefulness and shouldn't be used any more.

Replies are listed 'Best First'.
Re^2: Formatting of printed SQL Query output
by cool (Scribe) on Jun 29, 2007 at 08:57 UTC
    You can split your out putput based on the delimiter and I hope its spaces in your case (shown as \s+ below). And print these one by one giving a tab (shown as \t) between the columns. This should provide you with some basic alignment.
    foreach my $line(@query_output) { my ($comp_id,$comp_info)=split(/\s+/,<$line>); print "$comp_id\t$comp_info\n"; }
    Hope it would of some help.
    cheers, Syntex would be this: my ($comp_id,$comp_info)=split(/\s+/,$line);