title: Perl, determine where STDIN is coming from
body: <p>We have a number of cron jobs that collect various stats over a rather large network. Most of these cron jobs don't get monitored very well. I wanted to write a perl script that we could pipe the output of these jobs into, something like this:</p>
  
  <pre><code>5 * * * * collectstats.pl 2&gt;&amp;1 1&gt;/dev/null | scriptwatcher.pl
  </code></pre>
  
  <p>The idea is that stdout from collectstats.pl is discarded and stderr is piped into scriptwatcher.pl. This second script can then take appropriate action in the case of errors, most likely email me. With a quick test this is working except that in scriptwatcher I need to know the name of the script that is sending it errors. With just that one little piece of information everything I want to do becomes possible.</p>
  
  <p>Also, is it possible to pipe the stdout from collectstats into another script at the same time? ie 2 pipes for the one script?</p>
  
  <p>Cheers</p>