Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: Can't call method "otherwise" without a package or object reference at

by ig (Vicar)
on Oct 06, 2010 at 07:17 UTC ( [id://863727]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Can't call method "otherwise" without a package or object reference at
in thread Can't call method "otherwise" without a package or object reference at

It looks like you're missing a semicolon between the otherwise block and the die. It should be:

try { my ($k) = 2; throw sysAssert("test assert"); } catch err with { my ($ex) = @_; print "caught by with\n"; dPrt("warn"," with $ex"); } otherwise { my ($ex) = @_; print "caught by otherwise \n"; dPrt("warn","OTHERWISE:$ex"); }; die "got here";
  • Comment on Re^5: Can't call method "otherwise" without a package or object reference at
  • Download Code

Replies are listed 'Best First'.
Re^6: Can't call method "otherwise" without a package or object reference at
by rpelak (Sexton) on Oct 06, 2010 at 15:25 UTC
    Whoops. yep. Had that in all the others, missed it on this one. But adding it didn't change the result.
      What do you get from perl -MO=Deparse,-p script.pl for the offending chunk?
        I'll admit I haven't run the deparse before... so I can't read it very well (at least for this try catch stuff... But For the code that was added simply to prove that otherwise is defined.
        do { (my($k) = 2); 'sysAssert'->throw('test assert') }->try('err'->catch(do { (my($ex) = @_); print("caught by with\n"); dPrt('warn', " with $ex") }->with(do { (my($ex) = @_); print("caught by otherwise \n"); dPrt('warn', "OTHERWISE:$ex") }->otherwise)));
        For the original offending code that generates the error about can't call method "otherwise"... that I am trying to fix...
        if (($pbOnDStarMachine == 1)) { (my($sComm) = "sudo dchown nhmgenda '$$this{'sFullPath'}'"); do { libs::exec("$sComm") }->try('err'->catch(do { (my($ex) = @_); dPrt('warn', "$ex") }->with(do { (my($ex) = @_); dPrt('warn', "OTHERWISE:$ex") }->otherwise))); return(''); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://863727]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found