my $afile='dir1/firstfile.txt'; my $bfile='dir2/secondfile.txt'; my $bash_command='learn.sh '.$afile.' '.$bfile.' |'; open(my $output,$bash_command) or die $!; while(my $line=<$output>){ print "$line"; }