monkfan has asked for the wisdom of the Perl Monks concerning the following question:

This is a side question to my old posting. I hope it is not overly OT. Ok, how should I modify the script below
$ perl othercode.pl | perl thiscode.pl
If I want to get the output from 'othercode.pl' written into a file say "othercode.out", and then directly pass that output file to 'thiscode.pl' and see the result of 'thiscode.pl' at once. Yes, I mean in single command line? Is it possible?

I tried
$ perl othercode.pl > 'othercode.out' | perl thiscode.pl
still without being able to see the result of 'thiscode.pl'
Regards,
Edward

Replies are listed 'Best First'.
Re: Creating an outputfile and processing it at once
by sk (Curate) on Jul 28, 2005 at 07:45 UTC
    Assuming you are looking for non-perl related command line solution

     perl othercode.pl | tee othercode.out | perl thiscode.pl

Re: Creating an outputfile and processing it at once
by umbra (Acolyte) on Jul 28, 2005 at 07:47 UTC
    its definitely OT $ perl othercode.pl > othercode.out;perl thiscode.pl < othercode.out
      This runs the program twice unnecessarily ;)

      Not sure if it is a big deal or not but not required

      Update: umbra you mentioned that you are on windows and don't have access to tee. In such cases you can write your own tee. It is very simple.

      # Program tee #!/usr/bin/perl -w die "Usage: tee outfile\n" unless @ARGV == 1; open(OUT,'>', $ARGV[0]) or die $!; shift; while (<>) { print OUT; print; } close (OUT) or die $!;

      PS: I wasn't sure how to reply back to you with code as a /msg so decided to update this thread.