> I need to construct a working printf statement where each field in a given
> record
> would print at a specified position.
>
> Each record may or may not contain any particular field but will always
> begin with .VENDOR.LIBRARY. and end with .VENDOR.XINFO.END.
>
> Hope springs eternal for this novice perl scripter. If you can't help me,
> but can refer me to another list which might - I'd appreciate that.
>
> Pat Gorden-Ozgul
> [EMAIL PROTECTED] / [EMAIL PROTECTED]
>
>
> A sample from the datafile:
>
> .VENDOR_LIBRARY. BNL-MAIN
> .VENDOR_ID. 0000070001
> .VENDOR_NAME. Research Books, Inc. / scholium
> .VENDOR_GROUP2. DOMESTIC
> .VENDOR_ADDR1_BEGIN.
> .PHONE. 800 445 7359 203 245 3279
> .FAX. 203 245 1830
> .LINE. 38 Academy Street
> .CITY. Madison
> .STATE. Ct
> .ZIP. 06443
> .VENDOR_ADDR1_END.
> .VENDOR_ADDR2_BEGIN.
> .LINE. 38 Academy Street
> .CITY. Madison
> .STATE. Ct
> .ZIP. 06443
> .VENDOR_ADDR2_END.
> .VENDOR_XINFO_BEGIN.
> .PAYTO. Research Books, Inc. / scholium
> .VENDOR_XINFO_END.
>
> .VENDOR_LIBRARY. BNL-MAIN
> .VENDOR_ID. 0000070097
> .VENDOR_NAME. Aspen Publishers Inc.
> .VENDOR_GROUP2. DOMESTIC
> .VENDOR_ADDR1_BEGIN.
> .PHONE. (800)234-1660
> .LINE. 7201 McKinney Circle
> .CITY. Frederick
> .STATE. MD
> .ZIP. 21704
> .VENDOR_ADDR1_END.
> .VENDOR_ADDR2_BEGIN.
> .ATTN. Accounts Receivable
> .LINE. P.O. Box 64054
> .CITY. Baltimore
> .STATE. MD
> .ZIP. 21264-4054
> .VENDOR_ADDR2_END.
> .VENDOR_XINFO_BEGIN.
> .PAYTO. Aspen Publishers Inc.
> .VENDOR_XINFO_END.
>
> .VENDOR_LIBRARY. BNL-MAIN
> .VENDOR_ID. 0000070014
> .VENDOR_NAME. John Wiley and Sons, Inc.
> .VENDOR_GROUP2. DOMESTIC
> .VENDOR_ADDR1_BEGIN.
> .ATTN. Order Department
> .LINE. Eastern Distribution Center
> .LINE2. One Wiley Drive
> .CITY. Somerset
> .STATE. NJ
> .ZIP. 08875
> .COUNTRY. USA
> .PHONE. (800) 225-5945
> .VENDOR_ADDR1_END.
> .VENDOR_ADDR2_BEGIN.
> .ATTN. John Wiley & Sons, Inc.
> .LINE. P.O. Box 18684
> .CITY. Newark
> .STATE. NJ
> .ZIP. 07191-8684
> .COUNTRY. USA
> .PHONE. (908) 469-4400
> .VENDOR_ADDR2_END.
> .VENDOR_XINFO_BEGIN.
> .PAYTO. John Wiley & Sons, Inc.
> .VENDOR_XINFO_END.
>
> .VENDOR_LIBRARY. BNL-MAIN
> .VENDOR_ID. 0000070001
> .VENDOR_NAME. Research Books, Inc. / scholium
> .VENDOR_GROUP2. DOMESTIC
> .VENDOR_ADDR1_BEGIN.
> .PHONE. 800 445 7359 203 245 3279
> .FAX. 203 245 1830
> .LINE. 38 Academy Street
> .CITY. Madison
> .STATE. Ct
> .ZIP. 06443
> .VENDOR_ADDR1_END.
> .VENDOR_ADDR2_BEGIN.
> .LINE. 38 Academy Street
> .CITY. Madison
> .STATE. Ct
> .ZIP. 06443
> .VENDOR_ADDR2_END.
> .VENDOR_XINFO_BEGIN.
> .PAYTO. Research Books, Inc. / scholium
> .VENDOR_XINFO_END.
>
> .VENDOR_LIBRARY. BNL-MAIN
> .VENDOR_ID. 0000070001
> .VENDOR_NAME. Research Books, Inc. / scholium
> .VENDOR_GROUP2. DOMESTIC
> .VENDOR_ADDR1_BEGIN.
> .PHONE. 800 445 7359 203 245 3279
> .FAX. 203 245 1830
> .LINE. 38 Academy Street
> .CITY. Madison
> .STATE. Ct
> .ZIP. 06443
> .VENDOR_ADDR1_END.
> .VENDOR_ADDR2_BEGIN.
> .LINE. 38 Academy Street
> .CITY. Madison
> .STATE. Ct
> .ZIP. 06443
> .VENDOR_ADDR2_END.
> .VENDOR_XINFO_BEGIN.
> .PAYTO. Research Books, Inc. / scholium
> .VENDOR_XINFO_END.
>
>
> The code:
>
> ########################################
> # script: peoplesoft_vendors.pl
> # author: PGO
> # description: Generate PeopleSoft 'VN'vendor batch file
> # from API output
> # date: 01/31/03
> ########################################
>
> my $file_in = 'vendshrt';
>
> my $library = ".VENDOR_LIBRARY. ";
> my $library_out = " ";
> my $id = ".VENDOR.ID. ";
> my $id_out = " ";
> my $name = ".VENDOR_NAME. ";
> my $name_out = " ";
> my $payto = ".PAYTO. ";
> my $payto_out = " ";
> my $group2 = ".VENDOR_GROUP2. ";
> my $group2_out = " ";
> my $phone1 = ".PHONE. " ;
> my $phone1_out = " ";
> my $fax = ".FAX. ";
> my $fax_out = " ";
> my $addr1_line = ".LINE. ";
> my $addr1_line_out = " ";
>
> my $blank8 = " ";
>
> open(DATA, "$file_in") || die ;
>
> while (<DATA>)
> {
> chomp ($line);
> # debug
> # print "this line is: $_";
>
> if ($line =~ /$library/)
> {
> $line =~ s/$library//g;
> print $line;
> $library_out = $line;
> # debug
> print "library = $library_out";
> }
> if ($line =~ /$payto/)
> {
> $line =~ s/$payto//g;
> $payto_out = $line;
> }
> if ($line =~ /$id/)
> {
> $line =~ s/$id//g;
> $id_out = $line;
> }
> if ($line =~ /$name/)
> {
> $line =~ s/$name//g;
> $name_out = $line;
> }
> if ($line =~ /$group2/)
> {
> $line =~ s/$group2//g;
> $group2_out = $line;
> }
> if ($payto_out = " ")
> {
> $payto_out = substr($name_out,0,39);
> # debug
> print "Payto = $payto_out";
>
> }
> if ($line =~ /$phone1/)
> {
> $phone1_out = $line;
> }
> if ($line =~ /$fax/)
> {
> $fax_out = $line;
> }
> if ($line =~ /$addr1_line/)
> {
> $addr1_line_out = $line;
> # debug
> print "addr1_line_out = $addr1_line_out";
>
> }
> # printf "%8s %-40s %-26s \n", $blank8, $payto_out, $addr1_line_out;
>
> my $library = ".VENDOR_LIBRARY. ";
> my $library_out = " ";
> my $id = ".VENDOR.ID. ";
> my $id_out = " ";
> my $name = ".VENDOR_NAME. ";
> my $name_out = " ";
> my $payto = ".PAYTO. ";
> my $payto_out = " ";
> my $group2 = ".VENDOR_GROUP2. ";
> my $group2_out = " ";
> my $phone1 = ".PHONE. " ;
> my $phone1_out = " ";
> my $fax = ".FAX. ";
> my $fax_out = " ";
> my $addr1_line = ".LINE. ";
> my $addr1_line_out = " ";
>
> }
>
> close(DATA);
>
>