Pipes(in perl)

LogikWeaver

Registered
I am having trouble with getting pipes to work. I have one file called test1.pl that is the below:

#!/usr/bin/perl

print 'hi';

I also have a file called test2.pl in the same directory that is the below:

#!/usr/bin/perl

open(TEST, "test1.pl |")||die("error: $!");

$file=<TEST>;

print "Got this input: $file\n";

When I run test2.pl as "perl test2.pl" from the command line, the program dies, and says that there is no test1.pl

What is wrong? Thanks in advance
 
First thing I'd say is the directory containing test1.pl is not in your path. Try making the open contain the full path to test1.pl, or add '.' to your path, or finally, add this to test2.pl:

$ENV{ 'PATH' } .= ':.';
 
Thanks!
including the ./ in front of the test1.pl worked, whereareas appending onto the ENV variable did not, regardless of whether the ./ was there. Thanks again!
 
Back
Top