Don't use Switch! Nonsense errors like this is why.
Replace
with, for example,switch ($response_code) { case '200' { # OK print_response $response_content; exit 0; } case '400' { exit 1; } # BAD_INPUT case '403' { exit 31; } # SERVICE_ACCESS_ERROR case '500' { exit 32; } # SERVICE_EXECUTION_ERROR case '503' { exit 30; } # SERVICE_ERROR else { exit -1; } }
for ($response_code) { if ($_ == 200) { # OK print_response $response_content; exit 0; }; $_ == 400 and exit 1; # BAD_INPUT $_ == 403 and exit 31; # SERVICE_ACCESS_ERROR $_ == 500 and exit 32; # SERVICE_EXECUTION_ERROR $_ == 503 and exit 30; # SERVICE_ERROR exit 255; }
Note that I replaced exit(-1) with exit(255) since -1 isn't a valid exit code (at least not on Windows, Linux and macOS).
Seeking work! You can reach me at ikegami@adaelis.com
In reply to Re: backslash found where operator expected at
by ikegami
in thread backslash found where operator expected at
by tokodekat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |