View Single Post
Old 12-18-2012, 02:56 PM   PM User | #4
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,757
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
If you put some delimiters around each field's format specification, you'll be able to see more clearly the leading and trailing spaces between the fields. Based on that info, you should be able to see what adjustments you need to make.

See if this adjustment makes it more clear.
Code:
printf ("<%-8s> <%13.0f> <%-38s>\n", $original_line, $result, $user_folders);

You haven't clearly stated how the columns should line up, but Here's my test script which I think gives the output you desire.
Code:
#!/usr/bin/perl

use strict;
use warnings;

print <<'HEADER';
----------------------------------------------------------------------------------------------------------
domain\username    full name                 last access date       last access (days)     folder access
----------------------------------------------------------------------------------------------------------
HEADER

my $original_line = 'test\JOHN123       John Campbell             Fri 10-19-2012';
my $result = 59;
my $user_folders = 'EDITOR';

printf ("%-67s %-22.0f %-14s\n", $original_line, $result, $user_folders);
Outputs:
Code:
----------------------------------------------------------------------------------------------------------
domain\username    full name                 last access date       last access (days)     folder access
----------------------------------------------------------------------------------------------------------
test\JOHN123       John Campbell             Fri 10-19-2012         59                     EDITOR
FishMonger is offline   Reply With Quote