Well, I've made some changes... not sure if it was for the better but at
least I'm learning from the research! :-)
I don't think the split is really doing anything (but I'd like it to.. :-) )
and my format STDOUT is producing the error "Use of uninitialized value in
formline... ?? not sure what that means. Any suggestion would be great!
Thanks! Brian
--- new and not so improved code --------------
#!/usr/bin/perl -w
use strict;
my $datafile = "C:/brian/marion_sch.txt";
open (IN, $datafile);
while (<IN>) {
chomp;
my ($user_name, $full_name, $cust_name, $address, $csz, $blank_line) =
(split // );
write;
}
format STDOUT =
@<<<<<<<<<<<<< @>>>>>>>>>>>>>>>> @<<<<<<<<<<<<<<<
my $user_name, my $full_name, my $cust_name
.
close IN;
-----Original Message-----
From: Brian Volk
Sent: Wednesday, October 06, 2004 12:37 PM
To: Beginners (E-mail)
Subject: Format Database file
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]