http://www.perlmonks.org?node_id=1007333

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

Dear Monks,

The installation of a module fails (PDL in this instance). I am running Strawberry Perl. I just want to capture the cpan shell output for further examination.

I intuitively tried the following with no success:
cpan> install PDL > c:\path\logfile
Thanks for any suggestion

UPDATE: Needed to double escape the backslashes (Windows) in the path, I should have though of it. Thanks!
UPDATE 2: Clarification brought following greengaroo's reply, indeed one is in Perl when at the cpan prompt!

Replies are listed 'Best First'.
Re: Output capture of CPAN shell
by marto (Cardinal) on Dec 05, 2012 at 16:55 UTC
Re: Output capture of CPAN shell
by greengaroo (Hermit) on Dec 05, 2012 at 21:56 UTC

    Why do you think you need to double the backslash on Windows? It's not because of Windows, it's because Perl uses the backslash as the escape character.

    In your first attempt, Perl was trying to escape "p" and "l", converting regular characters to special characters, but then the path you were trying to reach didn't exists.

    In your second attempt, you double the backslash, basically you escape the special character "\" and it becomes a regular character, so Perl really see a backslash, and the path now exists.

    But, in Perl on Windows, you can also use the forward slash "/" in file paths.

    Hope this help you understand what was going on internally.

    Testing never proves the absence of faults, it only shows their presence.
Re: Output capture of CPAN shell
by LanX (Saint) on Dec 05, 2012 at 16:59 UTC
    cpan modulename >/tmp/log

    works for me

    Could be that you need to redirect STDERR too.

    cpan modulename >/tmp/log 2> /tmp/err

    Cheers Rolf