"You're not incrementing $line" was my first impression, but in fact you have $line as the text you want, then you use it as an array index which probably evaluates to zero. To top it off, you assign to $line using that.

Also, it's a good idea to open an close handles at the same level, and to check for errors on system interfaces like open. Your &get_text sub takes no arguments, and really doesnt seem to add much to the organisation. Here is a decrufted version:

use Fcntl qw(LOCK_EX); open DOM_WORK, '> /usr/spool/lpd/dom/dom.work' or die $!; LOCK: { flock DOM_WORK, LOCK_EX or die $!; } for (<>) { tr/\x0c-\x0d//d; print DOM_WORK or die $!; } close DOM_WORK or die $!; &get_domkey; # whatever that is
I added locking in case of contention for the file. You may want to redo instead of dying, so I threw in the bareblock around that. If dom.work is some sort of queue, you probably want to open it to append ('>>')

After Compline,
Zaxo


In reply to Re: Sub only grabbing first line from STDIN by Zaxo
in thread Sub only grabbing first line from STDIN 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.