Hi All,
I have a database file, some_sch.txt that is arranged like this:
username1
First Last
Some Community Sch
1000 S Adams St
Town, Indiana 12345 U.S.A.
username2
First Last
Some Community Sch
1000 S Adams St
Town, Indiana 12345 U.S.A.
username3
First Last
Marion Community Sch
1000 S Adams St
Town, Indiana 12345 U.S.A.
I want the file to look like this:
username1 First Last Marion Community Sch 1000 S Adams St Town,
Indiana 12345 U.S.A.
username2 First Last Marion Community Sch 1000 S Adams St Town,
Indiana 12345 U.S.A.
username3 First Last Marion Community Sch 1000 S Adams St Town,
Indiana 12345 U.S.A.
Here is what I have so far, I don't how to tell perl what is what in the
input file, I know this is a ways away from what I want, but if I could get
some help w/ the first part, I would really appreciate it.
I think I might need a next statement after each Scalar in the loop?
Thanks!
#!/usr/bin/perl -w
use strict;
my $datafile = "C:/brian/some_sch.txt";
open (IN, $datafile);
while (<IN>) {
chomp;
my $user_name = substr $_, 0, 15; # extract the last username field
my $full_name = substr $_, 0, 20; # extract the name field
my $cust_name = substr $_, 0, 40; # extract the customer name field
my $address = substr $_, 0, 30; # extract the address field
my $csz = substr $_, 0, 40; # extract the city, state and zip
field
print "$user_name $full_name $cust_name $address $csz\n";
}
close (IN);
Brian Volk
HP Products
317.289.9950 x1245
<mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]