Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Need a second set of eyes: Very odd failure

by karlgoethebier (Abbot)
on Nov 17, 2017 at 17:21 UTC ( [id://1203689]=note: print w/replies, xml ) Need Help??


in reply to Need a second set of eyes: Very odd failure

BTW, why don't you use a plain old module? I don't see any reason to OO here.

package NCS::PuppetDB::Data { use strict; use warnings; use JSON::Tiny qw(decode_json encode_json); use Net::Curl::Easy qw(:constants); use Exporter qw( import ); our @EXPORT_OK = qw( getHosts getHostFacts getFact); our $VERSION = '0.5.3'; sub getHosts { ... } sub getHostFacts { ... } sub getFact { ... } 1; }

Please correct me if i miss something. I added some of my favorite modules. No need to shell out for curling etc.

Update: But perhaps this layout is interesting for you:

NCS/PuppetDB/Data.pm

package NCS::PuppetDB::Data { use Role::Tiny; use JSON::Tiny qw(decode_json encode_json); use Net::Curl::Easy qw(:constants); use feature qw(say); say q(package ) . __PACKAGE__; sub getHosts { ... } sub getHostFacts { ... } sub getFact { ... } 1; }

BlueCowdawg.pm

package BlueCowdawg { use Class::Tiny; use Role::Tiny::With; use feature qw(say); with qw(NCS::PuppetDB::Data); say q(package ) . __PACKAGE__; 1; }

run.pl

#!/usr/bin/env perl use strict; use warnings; use Try::Tiny; use BlueCowdawg; use feature qw(say); say q(package ) . __PACKAGE__; my $fido = BlueCowdawg->new(); try { say $fido->getHosts(); } catch { warn $_; }; try { say $fido->getHostFacts(); } catch { warn $_; }; try { say $fido->getFact(); } catch { warn $_; }; __END__

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-25 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found