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)