in reply to Re^3: Perl Module Object - Return fail/success with a fault string
in thread Perl Module Object - Return fail/success with a fault string

I checked it into a google code SVN repo, so here ya go.

(Again, I still kinda consider myself a perl noob, atleast as far as creating perl modules goes and using OOP in perl, so don't hate! lol)

http://big-ip-f5-api.googlecode.com/svn/trunk/

Basically, if you look in the sample (which some of it works, some doesn't, I doubt you have an F5 laying around to test it on though), the code is as below

my $connection = BigIP::F5->new($settings); die ("Unable to connect to " . $settings{'server'} . "\nIt said: " . $ +connection->fault) if (!$connection);

I basically need the logic behind that to work, Yes I could make my module just die or croak, but id rather give the user the ability to end it in their own way if it throws a fail code

  • Comment on Re^4: Perl Module Object - Return fail/success with a fault string
  • Download Code

Replies are listed 'Best First'.
Re^5: Perl Module Object - Return fail/success with a fault string
by Corion (Patriarch) on Jan 03, 2012 at 21:10 UTC
    Please don't post (links to) offsite code. I prefer that you take the time to reduce your code (and problem) to a small, self-contained example.

    That said, your example API can be made to work by using overload to return a false value on which you still can call methods. I'm not sure whether that's the best API though. I would (also for testing purposes) split up the call to new and the call to connect, and have the call to connect just return a false value:

    my $conn = Net::Big5->new(...); $conn->connect or die $conn->error;

    That way you can make the call to connect fatal (via die) if it is in void context.