I made a few other posts regarding a project I am working on. All of the individual pieces seem to be working, the whole is another story. I am going to post some of the code and examples of the data files I am looking at in the hopes that someone might be able to point me in the right direction. The code is pretty messed up at this point, I just flipped it over starting with the last sub hoping that might help. When I execute the program I get endless Use of uninitialized value error msgs. I am new to Perl (painfully obvious). So any constructive critisism is very welcome. Here is the code:
#!/usr/local/bin/perl -w use strict; use PDF::Create; open DOM_WORK, '>/usr/spool/lpd/dom/dom.work' or die "Could not open f +ile because $!"; get_text(); close DOM_WORK; get_key(); sub custinvoice { open DOM_PRINT, '/usr/spool/lpd/dom/dom.work'; my @domtext = <DOM_PRINT>; my $pdf = new PDF::Create( 'filename' => 'invoice.pdf', 'Author' => ' STANPAK', 'Title' => 'Test Invoice to PDF', 'Version' => '1.2' ); my $page = $pdf->new_page( 'MediaBox' => [ 0, 0, 792, 612 ] ); my $f1 = $pdf->font( 'Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Arial' ); my $image = $pdf->image('InvoiceLand.jpg'); $page->image( 'image' => $image, 'scalex' => 1, 'scaley' => 1, 'xpos' => 0, 'ypos' => 0, ); my $y = 500; foreach ( 1 .. $#domtext ) { $page->string( $f1, 10, 40, $y, $_ ); $y = $y - 8; } $pdf->close; close DOM_PRINT; } sub get_domopts { print "Hello world"; my $dom_opts = shift; my @dom_opts = split ( //, $dom_opts ); my $cvtype = $dom_opts[0]; my $cvnumber = join ( "", @dom_opts[ 1 .. 10 ] ); my $dtype = join ( "", @dom_opts[ 11, 12 ] ); my $cdir = join ( "", @dom_opts[ 13 .. 15 ] ); my $dp = join ( "", $dom_opts[16] ); my $dpform = join ( "", @dom_opts[ 17, 18 ] ); my $dpnc = join ( "", $dom_opts[19] ); my $dprntr = join ( "", @dom_opts[ 20 .. 23 ] ); my $dpfill = join ( "", @dom_opts[ 24 .. 73 ] ); my $de = join ( "", $dom_opts[74] ); my $deform = join ( "", @dom_opts[ 75, 76 ] ); my $deadd = join ( "", @dom_opts[ 77 .. 176 ] ); my $defill = join ( "", @dom_opts[ 177 .. 226 ] ); my $df = join ( "", $dom_opts[227] ); my $dfform = join ( "", @dom_opts[ 228, 229 ] ); my $dfadd = join ( "", @dom_opts[ 230 .. 269 ] ); my $dftnbr = join ( "", @dom_opts[ 270 .. 283 ] ); my $dfdev = join ( "", @dom_opts[ 284 .. 287 ] ); my $dffill = join ( "", @dom_opts[ 288 .. 337 ] ); my $dsfcntl = join ( "", @dom_opts[ 338 .. 487 ] ); my $dx = join ( "", $dom_opts[488] ); my $dxtamp = join ( "", @dom_opts[ 489 .. 490 ] ); my $dxmot = join ( "", @dom_opts[ 491 .. 500 ] ); my $dxfill = join ( "", @dom_opts[ 501 .. 650 ] ); my $domfill = join ( "", @dom_opts[ 651 .. 750 ] ); if ( $cvtype eq "C" && $dtype eq "I" ) { custinvoice( $cdir, $dp, $dpform, $dpnc, $dprntr ); } sub get_domcf { my $key = shift; open DOM_CF, '/u/ds2/r61/domcf.dat' or die "Control file unavailable $!"; my @dom_cf = <DOM_CF>; while (@dom_cf) { if (/$key/) { } my $dom_opts = ($'); get_domopts($dom_opts); close DOM_CF; } sub get_key { open DOM_TEXT, '/usr/spool/lpd/dom/dom.work' or die "Could not open work file $!\n"; while (<DOM_TEXT>) { if (/\*([^*]+)\*/) { my $key = $1; close DOM_TEXT; get_domcf($key); } } sub get_text { while (<>) { tr/\x0c-\x0d//d; print DOM_WORK $_; } } } } } here is the data I am reading in from STDIN and writing to /usr/spool/ +lpd/dom.work: *C100102 I R61* yadd yadd yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda This is a bunch of data ...yadda yadda yadda Here is the data I am reading in from /u/ds2/r61/domcf.dat: C100102 I R61C100102 I R61Y3 1LP2 + YPFaseidas@megalink.net + + YLS68 Bridge Street, Suffield, CT 668-3001 F04 + CTED I R61CTED I R61YI 2DOM + YPS + + YS 68 BRIDGE STREET 668-3001 F04
Thanks in advance---bring the pain !

In reply to Use of uninitialized value errors by aseidas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.