in reply to Re: Re: Redirecting OUTPUT of system($command) to an array
in thread Redirecting OUTPUT of system($command) to an array

You have $command in single quotes, which do not interpolate the variable's value. You're trying to execute literal '$command'.

Update: Oops, no, that's backticks. Worse yet. You're trying to execute a file named by the text output by $command.

After Compline,
Zaxo

  • Comment on Re: Re: Re: Redirecting OUTPUT of system($command) to an array

Replies are listed 'Best First'.
Re^4:Redirecting OUTPUT of system($command) to an array
by Anonymous Monk on May 13, 2004 at 19:23 UTC
    I just implemented this line:
    my $pid = open my $sys, "-|", $command or die $!;
    And.... It work Gloriously!!!!
    Thanks for all your help!!!
      Yep, the two solutions here (using backticks or using open) aren't meant to be combined...
Re^4: Redirecting OUTPUT of system($command) to an array
by Anonymous Monk on Jul 15, 2005 at 15:53 UTC
    system("ls > holder.log"); #send the directory listing to a holder file open( TMPFILE, "holder.log" ) || die "Failed to create log file: $!\n"; @dirlist = <TMPFILE>; #read in the directory from the file to the array $fh = join(" ", @dirlist); #convert the array into a scalar for pattern matching close( TMPFILE ); #tidy up system("rm holder.log");
      Sorry first post

      system("ls > holder.log");             #send the directory listing to a holder file
      open( TMPFILE, "holder.log" ) || die "Failed to create log file: $!\n";
      @dirlist = <TMPFILE>;             #read in the directory from the file to the array
      $fh = join(" ", @dirlist);                 #convert the array into a scalar for pattern matching
      close( TMPFILE );                   #tidy up
      system("rm holder.log");