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

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");
  • Comment on Re^4: Redirecting OUTPUT of system($command) to an array

Replies are listed 'Best First'.
Re^5: Redirecting OUTPUT of system($command) to an array
by Anonymous Monk on Jul 15, 2005 at 16:08 UTC
    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");