Bingo! James. That takes care of label issue. I was even able to make it three columns instead of three. And change the space between columns. You've obviously been at this for a while and use the tightest code concepts I've seen.
By the way, how would you 'search' the incoming file to restrict what gets displayed? i.e. display only the labels for the Johnson's? Thanks James, you've been of meg-assistance. Bill __________________________________________________ On Wed, 24 Dec 2003, James Edward Gray II wrote: > On Dec 23, 2003, at 11:29 PM, Bill Jastram wrote: > > > Yes, this helps tremendously. Actually, your suggestions helped me > > make, > > what for me is, a quantum leap in the use of Perl. > > Good news. Always happy to help. > > > I am stuck, however, on the loop you suggested to output the processed > > @col arrays. I understand how you loaded them. And that, apparently, > > they > > are ready to be output. But the closest I've come getting anything out > > of > > them is the following: > > Well, let's see if we can come up with something... > > > #!/usr/bin/perl > > > > # use with: > > # perl jamescolumnsample testing.txt > > > > use strict; > > use warnings; > > > > #open CON, 'testing.txt' or die "File error: $!"; > > > > #my @CON = <CON> ; > > > > my(@col1, @col2, @col3); > > > > my $col = 1; > > while (<>) { > > I forgot to remove the newlines here and we probably should: > > chomp; > > > if ($col == 1) { push @col1, $_ } > > elsif ($col == 2) { push @col2, $_ } > > else { > > push @col3, $_; > > $col = 1; > > next; > > } > > $col++; > > } > > > > # that should load @col1, @col2 and @col3 > > # can you come up with an output loop for them that goes here? > > # col1 will be the last to empty, so loop until it's gone > while (@col1) { > my(@names, @addresses, @cities); # make lists for the output lines > # fill those lists > foreach (shift(@col1), shift(@col2), shift(@col3)) { > next unless defined $_; > my($first, $last, $address, $city, $state, $zip) = split /\t/, $_; > push @names, "$first $last"; > push @addresses, $address; > push @cities, "$city, $state $zip"; > } > > # print one row of contacts > foreach ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]) { > printf join(' ', ('%-30s') x scalar(@$_)) . "\n", @$_; > } > print "\n" if @col1; # add a separator > } # rinse, repeat... > > __END__ > > Unfortunately, I'm not where I can test code this morning, so I'll have > to just hope that works. Let me know if I made a mistake though and > I'll fix it as soon as I'm back at a compiler. > > Hope that helps you along, Bill. Keep working at it. > > James > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>