Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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 ( #863815=note: print w/replies, xml ) Need Help??


in reply to Re^5: 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

Whoops. yep. Had that in all the others, missed it on this one. But adding it didn't change the result.
  • Comment on Re^6: Can't call method "otherwise" without a package or object reference at

Replies are listed 'Best First'.
Re^7: Can't call method "otherwise" without a package or object reference at
by ikegami (Pope) on Oct 06, 2010 at 16:14 UTC
    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(''); }

        No surprise. It just confirms that Perl thinks you have indirect method calls where you didn't mean use such. In both cases.

        Could you place the following just before your sub and provide the output:

        BEGIN { no strict 'refs'; no warnings 'uninitialized'; printf("package %s\n", __PACKAGE__); for (qw( try catch with otherwise err )) { printf("%s: exists:%s defined:%s prototype:%s\n", $_, exists(&{$_}) || 0, defined(&{$_}) || 0, prototype($_), ); } }

        Update: Removed bad slashes.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://863815]
help
Chatterbox?
[moritz]: choroba in python I use jsonschema
[moritz]: I'm sure there's a Perl implementation of it too
[choroba]: it seems Kelp and similar help you a lot with dispatching, but how to do something similar with contents?
[moritz]: like JSON::Schema
[Corion]: ambrus++ # more bugs than lines
[Corion]: That's like "works on my machine" ;-)
[choroba]: I mean, I'd like to say "this path should run this sub, but first it should check the user is authenticated, has the following permissions, and the contents is valid against a given schema
[ambrus]: no, that means I haven't even tried to run it, might not even parse
[ambrus]: so it doesn't work on my machine
[choroba]: i.e. I know JSON::Schema, I'm just curious whether there's a ready solution to plug it into a web service

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (14)
As of 2016-12-08 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (141 votes). Check out past polls.