Capture output of open pipe to a file in perl

Hi,

I am trying to capture the output of the an open pipe in perl. but I am not sure how to do this. can some one please help me do that?

Below is the script I am using

Replace this:

open ( my $DAT, "paflink filename |") or die "Could not open $ARGV[0]: $!";

With this:

open(my $DAT, "-|", "paflink filename") or die $!;

Thanks - I tried the below code. It is able to capture the output in the Output.txt but its not capturing the output from the print lines which are within while loop.

open(my $DAT, "-|", " paflink -p /path/  ./InputFile.txt  Output.txt") or die $!;