Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm having troubles with opening a pipe to redirect the output of a dir command. The error happens in svn.pm, which is a part of the Windows debugging SDK and is intended to support source indexing for subversion repositories. The section where it goes wrong is:
my $hProcess; if ( ! open($hProcess, "dir $SourceRoot 2>&1 |") ) { ::warn_message("Unable to resolve directory: $!"); return(); }
$SourceRoot is an existing directory. The error that I get back via $! is "No such file or directory". The whole purpose of the above script (I did not write it, and I'm not a perl developper) is to get all source files in a directory and process those. Any ideas Luc

Replies are listed 'Best First'.
Re: Opening pipe : no such file or directory
by Corion (Patriarch) on Sep 08, 2015 at 07:48 UTC

    This is weird. Are you certain that $SourceRoot is valid? The following works for me:

    perl -wle "open($hProcess, 'dir Q:\\ 2>&1 |'); print for <$hProcess>"

    Maybe $SourceRoot contains whitespace but is not quoted properly for the shell?</c>

      :) It is possible to have a dir.exe which could confuse things :) as sometimes you're calling cmd.exe and sometimes you're not :)

Re: Opening pipe : no such file or directory
by Anonymous Monk on Sep 08, 2015 at 08:08 UTC

    Um, don't use "dir" to get a list of files, use Path::Tiny  my @files = path( '/somewhere/over' )->children( qr{\.pl$}i ); or File::Find::Rule  my @files = find( file => name => qr/\.pl$/, maxdepth => 1 , in => '/the/rainbow' );

    No, you don't have to use those exact modules but they're the most convenient