Harry Putnam wrote:
> I'm not used to writing perl scripts on windows. I'm having a
> problem where a system call dies but still performs the command.
> I don't think I understand how exit status is checked.
>
> my $target = "E:/some_dir/another_dir";
> system("mkdir $target") or die "Can't mkdir $target: $!";
>
> The script stops at the `or die' but looking in E:/ I see `dir' has
> been created. Also the error ouput ($!) has no value.
>
> I get this error:
> Can't mkdir E:/some_dir/another_dir At: blah blah line 23
>
> So the command didn't really fail but perl thinks it did.
>
> May be notable that the script is running on C: and the target is on E:
I'd suggest taking John's advice, and using native Perl functions. OTOH, you
could also try:
system("md $target") and die "Can't mkdir $target:";
Which would provide the effect you are seeking.
Greetings! E:\d_drive\perlStuff>perl -w
my $target = 'test';
system("mkdir $target") and die "Can't mkdir $target";
^Z
A subdirectory or file test already exists.
Can't mkdir test at - line 2.
Note that $! is not usable, and may be counerproductive, in this context:
Greetings! E:\d_drive\perlStuff>perl -w
my $target = 'test';
system("mkdir $target") and die "Can't mkdir $target: $!";
^Z
A subdirectory or file test already exists.
Can't mkdir test: No such file or directory at - line 2.
Joseph
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>