Help for this page

Select Code to Download


  1. or download this
    # Not portable to Windows
    sub shell_quote {
    ...
    
    my $cmd = join ' ', map shell_quote($_), @CreateList;
    system("$cmd > data/test.txt") and die;
    
  2. or download this
    open(my $fh_out, '>', 'data/test.txt') or die;
    open(my $pipe, '|-', @CreateList) or die;
    print $fh_out $_ while <$pipe>;
    
  3. or download this
    use IPC::Open2 qw( open2 );
    open(my $fh_out, '>', 'data/test.txt') or die;
    my $pid = open2('>&'.fileno($fh_out), '<&STDIN', @CreateList);
    waitpid($pid, 0);