##
# This is ls.pl
use strict;
use warnings;
use IPC::Open2;
# $^X is the path to my Perl
open2(*OUTPUT,*INPUT,"$^X", "cat.pl") or die "$!";
print INPUT "first line\nsecond line\n";
close INPUT;
my @result=##
perl ls.pl
####
RESULT:
first line
second line