second_program filename # as a command line option echo "filename" | second_program # piped into its standard input #### system "./second_program", $filename and die ... # pass it on the command line # note, system needs "and" for error checking open my $fh, "| ./second_program" or die ... # via stdin print $fh $filename; # (note, no comma on this line)