in reply to Problem with system ()
Well, system returns zero unless the program completely fails to start when it returns a -1. So, zero would only be returned if successful, meaning that die will be called. You could always call the Perl function chdir instead of calling system, or you could call system like
system("cd C:\temp") == 0 or die "Error!: $?";If you choose the chdir route remember that if you want to keep what you have, the "\" character is the escape character, so Perl will interpret this as "C:<tab character>temp". You have two choices. The first is escape the backslash so it will look like
chdir "C:\\temp" or die "ERROR!: $!";or ActiveState will accept "/" as the directory separator, so you could use
chdir "C:/temp" or die "ERROR!: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Problem with system ()
by Anonymous Monk on Mar 19, 2003 at 14:35 UTC |