in reply to How to send the Output from system command into a file

Mostly people would do this with the shell, but if you want to write it by hand, it probably looks something like this.
open my $cmd, "-|", qw(ls -al) or die $!; open my $file, ">", "filename" or die $!; while(<$cmd>) { print $file $_ }

If you're interested in stdout as well as stderr, IPC::System::Simple might have a role to play.

-Paul