rpelak has asked for the wisdom of the Perl Monks concerning the following question:
That is the offending code. The Exec proc is hereif ( $pbOnDStarMachine == 1 ) { my ($sComm) = "sudo dchown foo \'$this->{sFullPath}\'"; try { libs::exec("$sComm"); } catch err with { my ($ex) = @_; dPrt("warn","$ex"); } otherwise { my ($ex) = @_; dPrt("warn","OTHERWISE:$ex"); }; return ""; }
When I first ran into the error about "with" I did some research and found that you can get that error if an exception other than the one you named gets thrown. And they suggested the addition of the otherwise clause to catch those "other" exceptions. So I dropped one in to try and basically catch all errors and convert to a warning... But now the error is about the otherwise clause. AS far as my research is convinced it can't be about the error type that is getting thrown, so it must be something else, perhaps the otherwise isn't related... Anyone have any insight?sub exec { my ($comm) = @_; if ( dbg::debugOn() ) { dPrt("dbg","Debug, Would execute:\n$comm"); } else { dPrt("libs_verbose","Executing:$comm"); system("$comm"); if ($? == -1) { throw err("system command returned -1: $comm\nReason $!"); } elsif ($? & 127) { my ($sSig) = $? & 127; throw err("Command died with signal $sSig :$comm"); } else { my ($nExitVal) = $? >> 8; if ( $nExitVal != 0 ) { throw err("Command exited with value $nExitVal :$comm"); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't call method "otherwise" without a package or object reference at
by ikegami (Patriarch) on Oct 05, 2010 at 23:16 UTC | |
by rpelak (Sexton) on Oct 06, 2010 at 00:19 UTC | |
by ikegami (Patriarch) on Oct 06, 2010 at 02:25 UTC | |
by rpelak (Sexton) on Oct 06, 2010 at 05:05 UTC | |
by ig (Vicar) on Oct 06, 2010 at 07:17 UTC | |
| |
|
Re: Can't call method "otherwise" without a package or object reference at
by ikegami (Patriarch) on Oct 05, 2010 at 23:04 UTC |