Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Creating an outputfile and processing it at once

by monkfan (Curate)
on Jul 28, 2005 at 07:03 UTC ( [id://478851]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://478851]
Approved by sk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found