James:

Thanks for the sample and I agree it does work.

How can I create an array of just the first names for a file? 

This is what I have so far:
__________________________________________________

open (A, "testing.txt");

@A = <A>;

foreach ($n = 0; $n<10; $n++)
{

#Split each record into its fields
$item =  $A[$n];
@addArray = split( "\t", $item); #Splits each line into its tab fields
$first = $addArray[0]; #Breaks down array into proper fields
$last = $addArray[1]; 
$add  = $addArray[2]; 
$city = $addArray[3]; 
$state = $addArray[4]; 
$zip = $addArray[5]; 

printf  "\n%s %s\n%s\n%s %s %s\n", $first, $last, $add, $city, $state, 
$zip; 
_________________________________________________

What it seems I need now is to create arrays for each of the fields, so I 
can proceed to make three columns of labels.

Thanks for any assistance you can give me with this.

Bill J. 
__________________________________________________

On Fri, 19 Dec 2003, James Edward Gray II wrote:

> On Dec 19, 2003, at 12:04 PM, Bill Jastram wrote:
> 
> > We're getting closer. But lets say the first name of the first field 
> > in the first row is 'Bill'. And the first name of the first field in 
> > the second row is 'Lanette'. This command will not compensate for the 
> > difference in the length of the two first names. So, the alignment of 
> > the second fields in each row will not be correct. And so on ...
> >
> > Does this help you understand where I'm headed?
> 
> No sir, I'm afraid I don't:
> 
> perl -e '@names = (["Bill", "Gray"],["Lanette", "Jones"]); printf 
> "%-20s %-20s\n", $$_[0], $$_[1] foreach @names'
> 
> Bill                 Gray
> Lanette              Jones
> 
> The above DOES line up correctly, with a fixed width font.
> 
> If you need to adjust the size of the fields based on the names, you'll 
> need to make two passes.  First, find the longest lengths.  Then print.
> 
> printf() is doing the right thing though, as you can see above.
> 
> James
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to