in reply to Re^3: Get filename of STDOUT
in thread Get filename of STDOUT

ActivePerl build 810 (5.8.4) gives me the following:
> perl -e "print $0" -e > echo print $0 >test.pl > perl test.pl test.pl
5.6.1 on Linux gave me the same values for aproxamitly the same tests. (adjusting for shell differences)
Setting $0 has no noticeable effect on windows that I could see.

Replies are listed 'Best First'.
Re^5: Get filename of STDOUT
by gaal (Parson) on Aug 11, 2004 at 07:41 UTC
    Wow, I was really sure I did see this broken on Windows, but you're right, it does work.

    What really *doesn't* happen is this name being propagated to the process list (either ctrl-shift-esc or ps if using Cygwin). Apparently the Windows kernel doesn't honor changing $0 with the same method perl does it on unix.

    Now that I see I was wrong, I looked this up in perlvar:

    On some (read: not all) operating systems assigning to $0 modifies the argument area that the "ps" program sees. On some platforms you may have to use special "ps" options or a different "ps" to see the changes. Modifying the $0 is more useful as a way of indicating the current program state than it is for hiding the program you're running.

    I stand corrected!