I'm trying to get input from a file that has three pieces of information in it, a tracking number, a pager number, and the messaging service the pager is programmed on. The data is on separate lines, as in
tracking number pager number paging service
Below is how I'm getting the input.
$datafile = "CheckUPS.in"; open (DATAFILE, $datafile) or die "Input data not found.\n"; while (<DATAFILE>) { $TRACK = $_; chomp ($TRACK); $pager = $_; chomp ($pager); $service = $_; chomp ($service); } print "$TRACK $pager $service\n";
Here is where I'm generating the output file which a third-party program is going to read as input to generate the message to be sent to the pager. $status is the current status of the package, and $new is the current geographical location of the package when it was last scanned.
# Generate the outgoing notice, and send it if (!($old eq $new)) { open (FILE,">$WORKDIR/$MAILOUT") || die "Could not open file: $!\n +"; print FILE "MSG:\n"; print FILE "TO: $pager $service\n"; print FILE "CONTENTS: Package ID $TRACK is/was $status to $new\n" +; #print FILE "Status: $status\n"; #print FILE "Track#: $TRACK\n"; #print FILE "Old: $old\n"; #print FILE "New: $new\n"; print FILE "\n"; close (FILE); if (($PAGER)) { $PagerCmd = "echo \"Check UPS Tracking: $TRACK\" | $MAILBIN $P +AGER"; system "$PagerCmd"; } #$MailCmd = "cat $WORKDIR/$MAILOUT | $MAILBIN $EMAILS -s \"UPS Pac +kage Tracking: $status\""; #system "$MailCmd"; }
My last output file was
MSG: TO: Airtouch Airtouch CONTENTS: Package ID Airtouch is/was to
The paging service is listed as the recipient and the package ID number. For some reason, the status and location are not making it into the file as well. What should I check in my code?

In reply to Is this a correct way of obtaining input from a file? by cecil36

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.