On FreeBSD using Perl 5.6.1:

perl -e 'system("ls","-d","/");'    <-- This works, showing just "/"
perl -e 'system("ls"," -d","/");'   <-- This fails, showing "ls:  -d: No
such file or directory"

On FreeBSD using tcsh:

perldoc "-f" system        <-- This works
perldoc " -f" system       <-- The shell sees that it doesn't start with a -
and interperets it as a module to look up documentation for.

On Win2K using cmd:

dir "C:\ "                           <-- This works
dir " C:\"                           <-- Again, same issue, "The filename,
directory name, or volume label syntax is incorrect"

I think that this is pretty standard behaviour, and will be seen in various
examples on multiple system. I also think that this is indeed desirable.

-- Ryan

----- Original Message -----
From: "Randy Kobes" <[EMAIL PROTECTED]>
To: "Garth Winter Webb" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, March 22, 2002 5:43 PM
Subject: Re: Can't open perl script " -spi.bak"


> On 22 Mar 2002, Garth Winter Webb wrote:
>
> > On Fri, 2002-03-22 at 12:57, Robert Landrum wrote:
> >
> > > >That's is very weird, because this code doesn't seem to work:
> > > >
> > > >perl -e 'system("perl", " -e1") == 0 or die "oops"'
> > >
> > > Actually, that's not all that weird.  Most shells take care of
> > > stripping out garbage before setting the argument list.  Since
> > > system(LIST) doesn't use the shell, it's passing perl the literal "
> > > -e1" which perl won't recognize as a command line option (and
> > > correctly so in my opinion).
> >
> > Actually this isn't standard behavior.  I can't think of a situation
> > where I would want to use system to concatanate a string for me rather
> > than interpreting the string as an argument and act accordingly.  If you
> > check 'perldoc -f system', this is exactly what system is supposed to do
> > when given a program name and a list of arguments, so it looks like
> > 'systetm' may be buggy in the win32 version of perl
>
> This behaviour seems to be dependent on the Perl version and on
> the Win32 "shell" used - the leading whitespace in front of the
> 1st argument after the program name in the system() call didn't
> cause a problem on Windows 98 with ActivePerl 626 (which I used
> to develop that part of the Makefile.PL), but it does cause a
> problem on other Win32s with different ActivePerl versions.
>
> best regards,
> randy kobes
>

Reply via email to