Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

i've been working with OOP for a while now, and i think i'm getting the hang of it. Then yesterday i came across a problem that i thought would be simple to fix, and it being 10 minutes to 5 left it for the next day. Today i came in, sat down, and have proceeded to spend all day not figuring out what's going wrong.

So here's the rundown, i have a class server.pm that uses a bunch of functions in the directory called functions. The server class has an AUTOLOAD function so that of the myriad of things that the server can do, it does not need to load in all of its functions.

i got the server and all of it's functions working, added a function, everything continued to work, added another function, and everything fell apart. Somehow the server is infinite looping while trying to get to the new function. Doing a perl debug tells me that everytime it gets to the magical goto &$method rather than going to the function correctly (like it does with all other functions) it goes back to the top of the AUTOLOAD method. Even worse is that all of the variables are correct. Following is the code along with a few comments that should illistrate what's happening (according to 'perl -d').

... # in some other function $server->print_forms(add => $data); # this is the exact errant met +hod call ... # in the server class, here's the AUTOLOAD method sub AUTOLOAD { my $self = $_[0]; # Don't disturb the @_! It's important! print STDERR "AUTOLOADing new method into server module.\n" if $self->flag('verbose') > 1; my $method = our $AUTOLOAD; $method =~ s/[^:]+:://; print STDERR "Attempting to find method $method for server module.\n +" if $self->flag('verbose') > 1; $method = -e "functions/$method.pm" ? "functions/$method.pm" : do { $method =~ /^(.)/; <functions/$1*> }; # According to the debugger Exporter is being properly # called and printing out the %:: hash tells me that # %main::functions::print_forms does indeed make it # into the mainspace properly, so i know it's not failing if (eval { require $method }) { $method =~ s/^functions\/(.*)\.pm$/$1/; eval "import functions::${method}"; print STDERR "Found $method: goto in effect...\n" if $self->flag('verbose') > 1; goto &$method; # At this point, even though $method is 'print_forms' # and @_ is correct, it goes back up to the top of # the AUTOLOAD method instead of where it's supposed to go. + } else { warn "Couldn't find $method method for server:\n$@\n"; } }
i don't think it should be necessary to post any other code, but if i've made an assumption or if something isn't obvious just tell me what i need to post and i'll put it up. Also, in case it matters, i'm running this on a Solaris 9 box using Perl 5.8.0, but the code should be platform independant (although i can't vouch for perl 5.6.x compliant).

What confuses me most is that the AUTOLOAD method works for every other function that i've handed to it, and it doesn't seem to be the naming convention or improper variable content or anything else i can think of that's screwing this one method call up. So, to those monks who are just itching for something bizaare to deal with, could you please tell me what's going on? Also, how should i go about fixing this? i'm stumped...

jynx


In reply to infinite loop blues by jynx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found