Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hey everyone,

I have a situation at work in which managements desired solution is an email, .forward, and a perl script. Basically, it needs to process the email content, do some db stuff, and log some stuff.

As this is the first time I've done something like this, there's one thing in particular I do not understand. When I do this:

#!/usr/bin/perl while (<STDIN>) { -- process the email content } -- do the db stuff here open(FILE, ">logfile"); ---write to logfile close(FILE);
The file does not get opened and written to.

However, when I do this:

#!/usr/bin/perl open(FILE, ">logfile"); while (<STDIN>) { -- process the email content } -- do the db stuff here ---write to logfile close(FILE);
the file does get opened and written to.

My guess is that it has to do with I/O and buffering. The only thing I could think of was to set  $|=1;, but that didn't work. I could do it the second way, since its pretty trivial, but I would really like to know how to do it the first way.

As always, thanks for your wisdom

davidj


In reply to sending an email to a perl script by davidj

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 drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-18 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found