SPUG: redirecting STDIN

Andrew Sweger andy at n2h2.com
Fri Nov 5 16:16:05 CST 1999


On Nov 5, 1999 @ 1:46pm, Peter Dueber wrote:

> I have some code like this:
> 
> $x="some-string";
> system("TheirProg arg1 arg2..... <in_file>");
> 
> TheirProg expects input from either the file "in_file", or from STDIN if in_file 
> is equal to "-".  
> 
> I don't have the source for TheirProg and I would like STDIN to instead be the 
> contents of string $x.
> 
> Can this be done?

This is Perl, right?

open (F, "|TheirProg arg1 arg2") or die;
print F $x;

-- 
 Andrew Sweger <andy at n2h2.com>    N2H2, Incorporated
                                  900 Fourth Avenue, Suite 3400
 No thanks, I'll just have the    Seattle WA 98164-1059
     Linux with a side of Perl    http://www.n2h2.com/  (206) 336-2947




 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list