in reply to Executing / Retrieving Output from Command

dir likely is not an external program but a shell built-in. Thus your backticks fail, and thus $newTest is undef. You can inspect $? and $! for the error(s). Maybe you meant to run cmd /c dir, or maybe you wanted readdir, glob or File::Find?

Replies are listed 'Best First'.
Re^2: Executing / Retrieving Output from Command
by ikegami (Patriarch) on Mar 15, 2010 at 18:29 UTC
    Perl automatically tries cmd /c $command is executing $command fails (or something like that), so `dir` actually does work on Windows.

    I consider that a bug since it harms error reporting.

    >perl -e"print `dir /b`" bar foo Windows: >perl -le"`nonexistant`; print $?; print $! if $?==-1" 'nonexistant' is not recognized as an internal or external command, operable program or batch file. 256 unix: $ perl -le'`nonexistant`; print $?; print $! if $?==-1' -1 No such file or directory