perl-module

How do you specify a package version in Perl?

孤者浪人 提交于 2019-12-04 07:32:22
I'm a bit confused by conflicting advice between pre-5.10.0 documents and the more recent version module. Perl Best Practices makes it pretty clear that version strings ('v1.0.3') are bad and one is supposed to specify a version as follows: use version; our $VERSION = qv('1.0.3'); but the version module says that we're back to using version strings: use version 0.77; our $VERSION = qv("v1.2.3"); Have we regressed, or is there a reason behind this? ire_and_curses Your quote from Perl Best Practices is not quite right. Specifically, bare vstrings of the form our $VERSION = v1.0.3; are

How to print out Nagios Service UP Time Percentage from Nagios-Report Perl Module

前提是你 提交于 2019-12-04 05:24:16
I can print out Host UP Time percentage from Nagios-Report Perl Module with following code: #!/usr/bin/perl use strict ; use Nagios::Report ; my $x = Nagios::Report->new(q<local_cgi localhost nagiosadmin>) or die "Can't construct Nagios::Report object." ; $x->mkreport( [ qw(HOST_NAME PERCENT_TOTAL_TIME_UP) ], sub { my %F = @_; my $u = $F{PERCENT_TOTAL_TIME_UP}; $u =~ s/%//; }, 0, sub { my $F = shift @_ ; } ) ; $x->debug_dump ; But How can I only print out Service UP Time Percentage? I mean only output the percentage value. I tried many options but couldn't get it right. This will produce

RTF to TEXT conversion using perl

有些话、适合烂在心里 提交于 2019-12-04 05:03:09
问题 Can somebody tell me how can we convert the rtf file into text with all the tags, tables and formatted data using perl programming language ? @Ahmad Bilal , @petersergeant : I have been using the below code for RTF to TXT conversion and i am able to convert into text. But the problem is i am unable to capture table or image formats and even all the entities in the inputfile are not captured using the program. use 5.8.0; use strict; use warnings; use Getopt::Long; use Pod::Usage; use RTF:

Undefined subroutine &PDL::divide

↘锁芯ラ 提交于 2019-12-04 04:27:34
问题 I'm trying Perl's PDL in the following code: #!/usr/bin/perl -w use strict; use PDL::Core qw(pdl); use PDL::Math qw(isfinite); use PDL::Primitive qw(statsover); my $div = 4; my @array1 = (0..10); my $pdl_array = log(pdl(@array1)/$div); $pdl_array->where(!isfinite($pdl_array)) .= 0; my($mean,$stdev) = statsover($pdl_array); die $pdl_array,"\n",$mean," ",$stdev,"\n"; and I'm getting this error: Undefined subroutine &PDL::divide called at ./compare_const.pl line 10. Any hint, please?Thanks a lot

Perl's Net::(SSH vs SSH2 vs OpenSSH) — how should I compare them?

a 夏天 提交于 2019-12-04 02:30:17
Looking to execute a perl script on a remote machine via a Perl script. Appears one option is to use system() function and create an ssh key so the password is not required. Which leads me to the focus of this question, the other option appears to be to install and run one of these perl modules: Net::SSH Net::SSH2 Net::OpenSSH Besides the protocol used, what else should I be comparing with these Perl modules? indiv The Net::OpenSSH documentation has a section describing the pros and cons of each. Here are some excerpts related to the ones you are asking about, but the documentation lists more:

Self logging Perl modules (without Moose)

放肆的年华 提交于 2019-12-03 20:34:55
I have the same question as was asked HERE but unfortunately I cannot install Moose and I think the solution described there was particular to Moose. Can someone tell me how to the same in old school "use base" speak? To reiterate the question, I would like to have my base classes to have an automatic logging mechanism using Log4perl so if the user does not do anything I get some reasonable logging but if the user of my class needs/wants to overwrite the logger they can. Well, if you want to have role/mixin type behavior and such just like in the other answer, you could use vanilla multiple

Perl : Two packages in same file cannot import same package?

筅森魡賤 提交于 2019-12-03 20:33:31
This is an interesting Perl behaviour. (atleast to me :) ) I have two packages PACKAGE1 and PACKAGE2 which exports function with same name Method1() . As there will be so many packages which will export this same function, use -ing everything in a Perl file will be tedious. So, I have created a general include file INCLUDES.pm which will have these use s. INCLUDES.pm: use PACKAGE1; use PACKAGE2; 1; PACKAGE1.pm: package PACKAGE1; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw ( Method1 ); sub Method1{ print "PACKAGE1_Method1 \n"; } 1; PACKAGE2.pm: package PACKAGE2; use Exporter; our

Can't locate local/lib.pm in @INC at /usr/share/perl/5.14/CPAN/FirstTime.pm

帅比萌擦擦* 提交于 2019-12-03 17:47:50
问题 I am trying to use Perl the first time on my system which is Ubuntu 12.04. I have Perl v.5.14.2 installed. I looked up how to install Perl modules, so I started as follows: $ perl -MCPAN -e shell The wizard started configuring the environment as can be seen here: http://pastebin.com/5hn8vkb5 Though, it stopped in the middle with the following error message: ... Checksum for /home/john/.cpan/sources/authors/id/A/AP/APEIRON/local-lib-1.008009.tar.gz ok ---- Unsatisfied dependencies detected

How do I retrieve an integer's ordinal suffix in Perl (like st, nd, rd, th)

可紊 提交于 2019-12-03 16:08:18
问题 I have number and need to add the suffix: 'st', 'nd', 'rd', 'th'. So for example: if the number is 42 the suffix is 'nd' , 521 is 'st' and 113 is 'th' and so on. I need to do this in perl. Any pointers. 回答1: Try this: my $ordinal; if ($foo =~ /(?<!1)1$/) { $ordinal = 'st'; } elsif ($foo =~ /(?<!1)2$/) { $ordinal = 'nd'; } elsif ($foo =~ /(?<!1)3$/) { $ordinal = 'rd'; } else { $ordinal = 'th'; } 回答2: Use Lingua::EN::Numbers::Ordinate. From the synopsis: use Lingua::EN::Numbers::Ordinate; print

Should a Perl constructor return an undef or a “invalid” object?

丶灬走出姿态 提交于 2019-12-03 12:11:27
Question : What is considered to be "Best practice" - and why - of handling errors in a constructor?. "Best Practice" can be a quote from Schwartz, or 50% of CPAN modules use it, etc...; but I'm happy with well reasoned opinion from anyone even if it explains why the common best practice is not really the best approach. As far as my own view of the topic (informed by software development in Perl for many years), I have seen three main approaches to error handling in a perl module (listed from best to worst in my opinion): Construct an object, set an invalid flag (usually " is_valid " method).