in reply to exiting a subroutine neatly
sub foo { my $rc = 0; if (!$ssh->start_session($ssh_host)) { print "ERROR connecting to $ssh_host\n"; $rc = 1; goto end; } my ($ret,$err)=$ssh->execute('command1','expect1'); if ($err || $ret=~/Unknown command:/m) { $rc = 2; goto cleanup; } my ($ret,$err)=$ssh->execute('command2','expect2'); if ($err || $ret=~/Unknown command:/m) { $rc = 3; goto cleanup; } ... cleanup: $ssh->exit_session(); $ssh->close_session; end: return $rc; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: exiting a subroutine neatly
by Anonymous Monk on May 05, 2015 at 09:53 UTC | |
by Anonymous Monk on May 05, 2015 at 10:11 UTC | |
by salva (Canon) on May 05, 2015 at 10:51 UTC | |
by Anonymous Monk on May 05, 2015 at 11:08 UTC | |
by salva (Canon) on May 05, 2015 at 11:28 UTC | |
| |
by salva (Canon) on May 05, 2015 at 10:13 UTC | |
by Anonymous Monk on May 05, 2015 at 10:16 UTC |