in reply to Can't locate object method

As agoth has already suggested this error is probably due to the fact that Net::Telnet is either outside the perl library path or not on the machine at all. Check out the the perldiag manpage for more information about error messages, or better yet use diagnostics with strict and warnings.

Also watch out for indirect method syntax (which is new Net::Telnet @args as opposed to direct syntax like Net::Telnet->new(@args)[1]) as it's liable to trip you up if you're not exactly sure what it's doing. Here's an example of where it can be fatal

package foo; sub new { print "I'm in foo::new()\n"; bless {}, 'foo'; } 1; package main; sub foo { print "I'm in main::foo()\n"; } my $o = new foo; __output__ Bareword found where operator expected at - line 17, near "new foo" (Do you need to predeclare new?) syntax error at - line 17, near "new foo"
This is a particularly pathological case but it's something to be wary of all the same.
HTH

_________
broquaint

[1] there's even an argument to use the very explicit Net::Telnet::->new but I don't think I've seen a case yet where it's necessary ...

Replies are listed 'Best First'.
Re: Re: Can't locate object method
by demerphq (Chancellor) on Jun 24, 2002 at 12:19 UTC
    Hah. broquaint++ The indirect syntax is a recipie for error (too bad so many people (including luminaries) come from a C++ background and perpetuate the syntax in CPAN module documentation.)

    Another exaple of bizarreness that I came across was this:

    my $obj=new Foo::Bar->new('parameter');
    When using a dual purpose new (as in it works on classes and objects) the above wont raise an error and you may find yourself wondering why 'parameter' hasnt been passed to the returned object.

    Of course your example is more likeyly to happen.... Alas. :-)

    Yves / DeMerphq
    ---
    Writing a good benchmark isnt as easy as it might look.