in reply to Re: eval problem
in thread eval problem

Ok, so after some more RTFM (thanks!) I ended up trying this option, as it seemed best, however, now when I try to implement Sys::SigAction's "timeout_call" - which gives the following example:
use Sys::SigAction qw( timeout_call ); if ( timeout_call( 5 ,sub { $retval = DoSomething( @args ); } ) { print "DoSomething() timed out\n" ; }
And I implemented this as, e.g.:
177 eval { 178 if ( timeout_call( 10, sub { $ret = system($mnt_cmd) +; } ) 179 { 180 logit ("Couldn't get to $smbdest, and couldn' +t mount it running $mnt_cmd"); 181 return 1; 182 }
I get the following error:
[support@hydra script]$ ./cfg_sucker.pl syntax error at ./cfg_sucker.pl line 179, near ") {" syntax error at ./cfg_sucker.pl line 186, near "}" Execution of ./cfg_sucker.pl aborted due to compilation errors.
What am I doing wrong syntactically? I've looged around, and this appears to be kosher?? TIA!

Replies are listed 'Best First'.
Re^3: eval problem
by BrowserUk (Patriarch) on Jan 10, 2007 at 16:23 UTC

    You have a missing close paren ')', Missing close curly '}' and missing final semicolon ';':

    eval { if ( timeout_call( 10, sub { $ret = system($mnt_cmd); } ) # 1 2 2 ? { logit("Couldn't get to $smbdest, and couldn't mount it running $ +mnt_cmd"); return 1; # ?? missing '}' } ## <<< missing ;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      yea, I was missing a paren, sheesh, sometimes it just takes a second pair of eyes... thanks!
        So, this does appear to work now, however, I've run into another related problem. Although the call does time out, when it does it segfaults and corrupts my bash shell. Using the following code:
        eval { logit ("Attempting to send os password to ssh object for $cust | $ +alias") if ($debug==1); if ( timeout_call( $alarm_timer, sub { $ssh2->auth_password($os_us +er,$os_pass); } )) { logit ("log in failed\n"); $popout = 8; return 8; } }; return $popout if ($popout > 0);
        The second return is to "pop" me out of my subroutine. Here is what happens:
        Tue Jan 16 15:01:16 2007: Attempting to send os password to ssh object < 2rootssh-connectiopasswordsiszSegmentation fault [support@hydra script]$
        Although it doesn't look like it does above... it's full of odd ASCII characters. Any ideas? I'm using 0.12 of libssh2, my best guess is that this is a libssh2 bug, which I don't think is fixed in the latest release (0.14) - although getting that to compile on RHEL4 is another thread on another board. :-(