Can someone provide a quick explanation of the use of Expect? The example I'm seeing doesn't search well in Google and I'm not sure why it's written the way that it is.

Here is my sample code:

Code:
...some code...

# $exp is using an SSH connection to send commands and wait for responses
#
$exp->send("$cmd\n");

$exp->expect(60, -re => $prompt, -re => $closed, -re => $error);

switch( $exp->exp_match_number) (
 case 0 {
   # Timeout!
 }
 case 1 {
   # Comand prompt
 }
 case 2 {
   # Connection closed
 }
 case 3 {
   # Error message
 }

...etc.
Why the "-re => $prompt" instead of just "$prompt"?

is
$exp->expect(60, -re => $prompt, -re => $closed, -re => $error);
the same as
$exp->expect(60, $prompt, $closed, $error);
or
$exp->expect(60, '-re', $prompt, '-re', $closed, '-re', $error);
?

What would be the best way to write this expect statement if I want to do a regex match on $prompt, but literal matches on $closed and $error?

Thanks!