perl-module

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

爱⌒轻易说出口 提交于 2019-12-05 16:03:08
问题 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? 回答1: The Net::OpenSSH documentation has a section describing the pros and cons of

How to install JSON.pm perl module on OSX

时光毁灭记忆、已成空白 提交于 2019-12-05 15:02:36
问题 I am trying to use the po2json parser/converter from the JS gettext library (http://jsgettext.berlios.de/), but when I try to convert I get this error: Can't locate JSON.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread

$SIG{INT}='IGNORE' not working with Net::OpenSSH

扶醉桌前 提交于 2019-12-05 14:11:51
I need to execute commands via $ssh->system in background, and it is documented that this should behave just like the local "system" command: 'As for "system" builtin, "SIGINT" and "SIGQUIT" signals are blocked. (see "system" in perlfunc).' Actually, this does not seem to be true, as $ssh->system in a child is immediately terminated when SIGINT is received, even when I explicitly want to "IGNORE" it first: use warnings; use strict; use POSIX ":sys_wait_h"; use Net::OpenSSH; my $CTRLC=0; $SIG{CHLD}='IGNORE'; sub _int_handler { $CTRLC++; print "CTRL-C was pressed $CTRLC times!!!\n"; } $SIG{INT}=

Installing XML::Parser requires expat.h

你说的曾经没有我的故事 提交于 2019-12-05 13:55:34
I'm working on a project that requires all third-party (read: CPAN) perl modules to be installed in a perforce repository, so that any code that depends on them can be successfully run without anyone else needing to manually install them. I ran into an issue though when trying to install XML::Parser. I use cpanminus to install my CPAN modules, so I ran cpanm -L . XML::Parser in the desired directory (this has worked before with other modules) and got the error: Expat.xs:12:19: error: expat.h: No such file or directory I'm used to using Ubuntu and apt-get, but at work I have to use RedHat and I

progress bar in command line perl script

回眸只為那壹抹淺笑 提交于 2019-12-05 10:30:05
I am trying to print progress in % in command prompt. But it is not working properly. I want to print the progress as :: Status 10% Completed when 20% will complete it will show Status 20% Completed in that same place not in new line. Could you please help me. Code:: $count++; $per=($count/$total)*100; print "\nStatus: $per Completed.\r"; sleep 1; You can do something like this: use strict; use warnings; use Time::HiRes qw(usleep); local $| = 1; my @nums = 1 .. 20; foreach my $c (@nums) { print "$c"; usleep(100000); print ("\b" x length($c)); } print "\n"; The module Term::ProgressBar seems to

Read MS Word table data row wise using win32:ole perl

寵の児 提交于 2019-12-05 07:40:46
I am new to win32:ole module in perl. I am trying to print MS word table data row wise on command prompt. But I am able to print only last row of the table. Can you please help me to solve this problem? Thanks in advance. Below is my code: #!/usr/bin/perl use strict; use warnings; use File::Spec::Functions qw( catfile ); use Win32::OLE qw(in); use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; my $word = get_word(); $word->{DisplayAlerts} = wdAlertsNone; $word->{Visible} = 1; my $doc = $word->{Documents}->Open('C:\\PerlScripts\\myTest.docx'); my $tables = $word->ActiveDocument->{

How to make a HTTP PUT request using LWP?

☆樱花仙子☆ 提交于 2019-12-05 06:13:50
I'm trying to change this request to a HTTP PUT request, any idea how ? my $request = LWP::UserAgent->new; my $response = $request->get($url, "apikey", $apiKey, "requestDate", $requestDate); You should use HTTP::Request: use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new("PUT", $url); my $res = $ua->request($req); As of 6.04, LWP::UserAgent has a put helper, so you can now do: $ua->put( $url ) PUT is HTTP::Request::Common. You can build the request first and pass it into user agent. use HTTP::Request::Common; use LWP; $agent = LWP::UserAgent->new;

How can I 'use' specific version of a perl CPAN module?

孤者浪人 提交于 2019-12-05 05:18:09
I have a lot perl code that does different things in test and production, and I want to lock my code to specific versions of CPAN modules in case there are some changes to some of them in the future which may possibly break my code. So I want to use specific versions of all the modules I use. By use I mean use XML::Smart To use specific module refer only use only MyModule => 0.30; Also to print error if module version you want is above to currently installed one You can say use XML::Smart v1.6.9; or use XML::Smart 1.6.9; or for backward compatibility use XML::Smart 1.006_009; With reference

Self logging Perl modules (without Moose)

雨燕双飞 提交于 2019-12-05 04:12:37
问题 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. 回答1: Well, if you

What is the difference between <stdin> and <STDIN>?

萝らか妹 提交于 2019-12-05 00:31:59
When I use <stdin> in Perl module ( *.pm ) files it's not reading input from the keyboard, but when I use <STDIN> in the same place it works fine. Why is it not getting input when I use <stdin> ? STDIN is the documented filehandle. There exists stdin as well, which is aliased to STDIN , but it only works in the main:: package: main::stdin is the same as main::STDIN (as documented in perlop - Perl operators and precedence ). In a package, therefore, package My::Package; sub xx { print while <stdin>; } stdin is interpreted as My::Package::stdin , which doesn't exist. You can use main::stdin from