Chad Kellerman wrote: > Sorry everybody, > > I have been trying to work on this all day but nothing... > > IF a perl module uses: > connect($sock, sockaddr_in($rport, $raddr)) > or die "Can't connect to $ssh->{host}, port $rport: $!"; > > How do I catch the die() in an eval statement; I have been using: > > eval { > alarm 10; > $ssh->login($user); > ($out, $error, $exit) = $ssh->cmd($cmd); > alarm(0); > }; # end of eval statement > if ($@ =~ /Can't/) { > try_again($ip, $host_name) = @_;
you put your try_again() function in the left side of the '=' operator. i am not sure if that's just your typo or not. but you can only do this if your function returns a lvalue like: sub try_again: lvalue{ #-- must return a lvalue(basically, not a constant); return $var; } otherwise, it won't even compile. the following catches the die() signal: eval{ function(); }; if($@){ another_function($@); }else{ print "nothing happened\n"; } sub function{ die "whatever"; } sub another_function{ print shift; } if you don't like to use the eval{}, $@ stuff, you can set up a __DIE__ handler like: $SIG{__DIE__} = sub { .... }; david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]