Yes, this helps tremendously. Actually, your suggestions helped me make,
what for me is, a quantum leap in the use of Perl.
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:
__________________________________________________
#!/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 (<>) {
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?
my($first, $last, $add, $city, $state, $zip) = split /\t/, $col1[$col];
printf "\n%s %s\n%s\n%s %s %s\n", $first, $last, $add, $city, $state,
$zip;
Any futher help with this would be appreciated.
Bill J.
__________________________________________________
On Tue, 23 Dec 2003, James Edward Gray II wrote:
> On Dec 23, 2003, at 12:17 AM, Bill Jastram wrote:
>
> > After taking a look at your last suggested script I have a short
> > question:
> >
> > At what point does this script read in information from the
> > source file 'testing.txt'?
> >
> > Is it during the 'while (<>)' statement? If so what would the syntax
> > be?
>
> Yes, you've got it.
>
> while (<>) {
>
> }
>
> is a construct for writing Unix-like filter apps. It reads one line at
> a time, from all the files passed as args to the script or STDIN, if
> none are given. This is extremely handy.
>
> For example, if you wanted to combine two text files for your mailing
> labels, you would just need to change how you call it:
>
> perl script_name testing.txt other_file.txt
>
> ...or even...
>
> perl script_name *.txt
>
> ...for all the .txt files in the current working directory.
>
> Hope that helps.
>
> James
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>