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
-
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.
|