Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2024-04-23 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found