in reply to Re: Setting the time on a Windows machine
in thread Setting the time on a Windows machine

Why do you preprend cmd /c when Perl will call the shell to handle a system SCALAR call anyway?

Makeshifts last the longest.

  • Comment on Re^2: Setting the time on a Windows machine

Replies are listed 'Best First'.
Re: Re^2: Setting the time on a Windows machine
by BrowserUk (Patriarch) on Jul 08, 2002 at 14:50 UTC

    Because I read this from perldoc:perlfunc:

    • If there is only one scalar argument, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system's command shell for parsing (this is /bin/sh -c on Unix platforms, but varies on other platforms). If there are no shell metacharacters in the argument, it is split into words and passed directly to execvp, which is more efficient.

    Which, as I know time is a CMD built-in, implied to me that as there are no shell meta characters involved, would mean that I would need to force the use of CMD explicitly.

    I have just tried it without and it works fine so I guess ActiveState have never updated the documentation to reflect the difference on the Win32 platform.

    Thanks for pointing it out. Another peice of 'cargo cult' programming, if I understand the term correctly, bites the dust :^)

      Hrm. Now the question is, can that behaviour be expected to remain as is? Since the docs were not updated, it may well be implementational detail.. I guess the safe way to achieve exactly predictable behaviour would be system "cmd.exe", "/c", "time $time"; as that is guaranteed to call the given program without going through the shell - except we happen to be calling the shell.

      Makeshifts last the longest.

        Point well taken.